-
Notifications
You must be signed in to change notification settings - Fork 40k
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
kubectl --validate should report line numbers of JSON syntax errors #12231
Comments
Sorry. The standard Go json parser has a number of limitations. We've been exploring alternatives: #3338. |
Thanks Brian, On Tue, Aug 4, 2015 at 9:55 PM, Brian Grant notifications@github.com
|
The error you got ( |
line number is exactly what I was expecting. The whole point of opening this issue is to highlight that the current JSON parser makes JSON configs pretty much unusable. The cryptic error messages makes triaging syntax errors in relatively large JSON files intractable. I assumed that's the reason this issue was kept open and tagged with priority 1. @lavalamp don't see the point of closing this issue without having a clear roadmap as to when and how its going to be resolved. At the very least we need to highlight this limitation in documentation and ask people to use an external parser to triage their JSON config issues. |
@asridharan OK, thanks for clarifying. I've changed the name of this issue to be more accurate. We will probably be changing the json parser we use eventually. |
Thanks @lavalamp |
Sorry, I meant to reopen, too. :) |
Note that we want to be able to do this for YAML, too, and we already know that we lose ordering information when converting from yaml to json. |
Concrete examples where line numbers would help:
cc @thockin |
Automatic merge from submit-queue Display line number on JSON errors Related issue: #12231 This PR will introduce line numbers for all JSON errors in the CLI: (this is existing error reporting for YAML) ```console $ kubectl create -f broken.yaml yaml: line 8: mapping values are not allowed in this context ``` (this is error reporting proposed in this PR for JSON) ```console $ kubectl create -f broken.json json: line 35: invalid character '{' after object key ``` (and this is the current reporting:) ```console $ kubectl create -f broken.json invalid character '{' after object key ``` [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
@bgrant0607 for:
I guess you mean here: The original PR #25038 is good, but if we can move this error handling to specific decoder, I think we can solve the remaining issues. |
Done as much as it's going to be for 1.3. |
Issues go stale after 30d of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
I have the following JSON config:
Turns out there was a syntax error in the JSON file (I have tagged the line with ">>>>>>>>error"). However, when I gave this replication controller config to kubectl for validation the error was cryptic:
I had to use an online tool to validate my json file, before getting it through kubectl. I moved from YAML to JSON thinking that it would be easier to manage declarative configs due to the indented (curly braces) syntax. However, seems like the kubectl JSON parser is rudimentary, at best, and definitely needs to be improved for better usability.
The text was updated successfully, but these errors were encountered: