New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow up on #4660: new app error msg #4743
Follow up on #4660: new app error msg #4743
Conversation
@smarterclayton what do you think of this approach? You suggested of a different type of error that would not be ignored by resolvers, but there are many places in the code path of new-app that ignores errors and/or replace them with new errors, what makes it difficult to solve the abstraction leak with a simple change, or at least I could not find one simple change that would do the trick. The current solution here is to catch the SyntaxError and print a message to Stderr immediately, what would make it like this:
The problem with this is that it might stutter:
|
@smarterclayton Bump |
@rhcarvalho squash please. lgtm otherwise. |
lgtm |
0c0718d
to
99a349e
Compare
This got quite aged. Here's how it is affecting the scenario described in the PR description: $ cat template.json
{"broken a. Current state before the PR: $ oc new-app template.json
error: invalid character '\n' in string literal b. With the changes introduced in this PR: $ oc new-app template.json
template.json at offset 9: invalid character '\n' in string literal
error: no match for "template.json", specify --allow-missing-images to use this image name.
The 'new-app' command will match arguments to the following types:
1. Images tagged into image streams in the current project or the 'openshift' project
- if you don't specify a tag, we'll add ':latest'
2. Images in the Docker Hub, on remote registries, or on the local Docker engine
3. Templates in the current project or the 'openshift' project
4. Git repository URLs or local paths that point to Git repositories
--allow-missing-images can be used to point to an image that does not exist yet.
See 'new-app' for examples. Hmm The initial motivator for this change was to try to address @smarterclayton's comment about leaking an abstraction... Do we still want to fix the abstraction leak? If so, I'd look for a different solution. Otherwise I'll just close this. |
i'd still like to clean it up, i kinda hate where that isFile logic lives right now. |
as for the right fix... yeah if we had an exact match (of the file "template.json" in this case) we should not be also assuming it might be an image name for an image we couldn't even find. (if there were an image named "template.json", that would be a different story.... in that case we should return a multiple match error, they should then specify the file explicitly, and then they should get an error that the file is invalid) |
Yep, it's ugly, but what worked back then. I'm +1 on making it better. I'll probably defer finding a more appropriate fix post dev-cut, is that alright? |
yup, that's the right priority. |
As long as we think users won't be confused by the error output this is fine.
|
it seems a little confusing, but i could be convinced to live with it and merge this if you're actually ok with it :) |
I'm not ok with the output after the current state of this PR. It's very easy to miss the error message in the first line. I'd miss it if I was not intentionally looking for it. |
(note to self) this PR might simply die after #6670 merges. |
be77e37
to
46b8b97
Compare
The little improvement that was present here and not included in #6670 is printing the offset where a syntax error happened: $ oc new-app template.json
error: unable to load template file "template.json": at offset 9: invalid character '\n' in string literal
error: no match for "template.json"
... @bparees PTAL [test] |
46b8b97
to
df1f5e9
Compare
LGTM - maybe add a test for it? |
@smarterclayton the test in |
lgtm [merge] |
continuous-integration/openshift-jenkins/test Running (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/861/) |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/4866/) (Image: devenv-rhel7_3346) |
Evaluated for origin merge up to df1f5e9 |
Evaluated for origin test up to df1f5e9 |
Given a JSON template with invalid syntax:
Before #4660,
oc new-app
produced this error message:After:
But @smarterclayton commented that the implementation was leaking an abstraction, thus, this follow up.