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

Silence "config warnings" in text mode, except for config ... commands #2641

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Jun 17, 2024

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Prints configuration warnings in text mode only if running one of the config ... commands.
Previously if there was an error in the configuration file, the warning was printed on all commands run from the cli.
In JSON mode the warning is always returned.

Also improve the error message from:

schema not defined for key 'asdasd'

to

Invalid value in configuration: schema not defined for key 'asdasd'

What is the current behavior?

$ arduino-cli version 
schema not defined for key 'asdasd'
arduino-cli  Version: 0.0.0-git Commit:  Date: 
$ arduino-cli version --json
{
  "Application": "arduino-cli",
  "Commit": "",
  "Date": "",
  "Status": "",
  "VersionString": "0.0.0-git",
  "warnings": [
    "schema not defined for key 'asdasd'"
  ]
}
$ arduino-cli config get directories.data
schema not defined for key 'asdasd'
/home/cmaglie/.arduino15

What is the new behavior?

$ arduino-cli version
arduino-cli  Version: 0.0.0-git Commit:  Date: 
$ arduino-cli version --json
{
  "Application": "arduino-cli",
  "Commit": "",
  "Date": "",
  "Status": "",
  "VersionString": "0.0.0-git",
  "warnings": [
    "Invalid value in configuration: schema not defined for key 'asdasd'"
  ]
}
$ arduino-cli config get directories.data
Invalid value in configuration: schema not defined for key 'asdasd'
/home/cmaglie/.arduino15

Does this PR introduce a breaking change, and is titled accordingly?

Other information

Partially fix #2638

@cmaglie cmaglie added type: enhancement Proposed improvement topic: CLI Related to the command line interface labels Jun 17, 2024
@cmaglie cmaglie self-assigned this Jun 17, 2024
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.28%. Comparing base (3f0d43f) to head (0beb1b6).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2641      +/-   ##
==========================================
- Coverage   70.29%   70.28%   -0.02%     
==========================================
  Files         222      222              
  Lines       21308    21309       +1     
==========================================
- Hits        14978    14976       -2     
- Misses       5153     5155       +2     
- Partials     1177     1178       +1     
Flag Coverage Δ
unit 70.28% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on ubuntu is working.

Is it intentional that when requesting the command below the json output omits the warnings key, but when requesting with a subcommand different from config the warnings key appears?

$ arduino-cli config get directories.data --json

"/home/ale/.arduino15"

$ arduino-cli version --format json
{
  "Application": "arduino-cli",
  "Commit": "",
  "Date": "",
  "Status": "",
  "VersionString": "0.0.0-git",
  "warnings": [
    "Invalid value in configuration: schema not defined for key 'asldfasdfasdf'"
  ]
}

@cmaglie
Copy link
Member Author

cmaglie commented Jun 17, 2024

Is it intentional that when requesting the command below the json output omits the warnings key, but when requesting with a subcommand different from config the warnings key appears?

Yes, that's because the returned JSON is a string and there is no way to fit a warning field inside.
We should have made it an object instead, like:

{
  "value": "/home/ale/.arduino15",
  "warnings": [
    "Invalid value in configuration: schema not defined for key 'asldfasdfasdf'"
  ]
}

but now it's too late, it would be for CLI 2.0.0 :-)

@cmaglie cmaglie merged commit 7219aa8 into arduino:master Jun 17, 2024
98 checks passed
@cmaglie cmaglie deleted the silence_config_warnings branch June 17, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schema not defined for key 'sketchbook_path' / monitor command now requires FQBN -b ...
2 participants