Skip to content
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

Better error when an invalid value is provided for the --json flag #1825

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shreyas-goenka
Copy link
Contributor

@shreyas-goenka shreyas-goenka commented Oct 10, 2024

Changes

I found myself making this mistake multiple times where I forget to include @ before the path and the error returned is confusing. This PR improves that bit of UX.

Before:

➜  cli git:(better-json-error) databricks jobs create --json .codegen.json
Error: invalid character '.' looking for beginning of value

After:

➜  cli git:(better-json-error) cli jobs create --json .codegen.json
Error: failed to parse JSON string. Please ensure that the value provided to the --json flag is either a valid JSON string or @path/to/file.json with valid JSON content: invalid character '.' looking for beginning of value

Tests

manually

@shreyas-goenka shreyas-goenka marked this pull request as ready for review October 10, 2024 13:39
@shreyas-goenka shreyas-goenka changed the title Return more presriptive error when user enters an invalid value for --json flag Better error when an invalid value is provided for the --json flag Oct 10, 2024
@andrewnester
Copy link
Contributor

I'd prefer it to be built on top of this PR because it changes a lot how we load JSON input and new error message likely belong to new json loader

#1771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants