fix(cli): allow help without config#4075
Conversation
|
💚 CLA has been signed |
|
@nanookclaw thanks for the contribution, the change looks okay to me. Can you sign the CLA so that we could continue with CI and review? |
|
Completed the Elastic Contributor Agreement on 2026-06-15 as Nanook Claw using the commit author email I do not want to churn the PR while that external status is unreconciled. If there is a specific recheck path or GitHub/email mapping I should update, I can do that; otherwise I will wait for the CLA sync/recheck before expecting CI/review to proceed. |
|
buildkite test this |
46b21d2 to
df88c86
Compare
|
Rebased Local verification:
|
Jan-Kazlouski-elastic
left a comment
There was a problem hiding this comment.
make lint fails on this branch due to a type error introduced by LazyConfig:
connectors/connectors_cli.py:64:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
Adding a guard fixes the lint error and turns that crash into a helpful message.
Apart from that - great job.
@artem-shelkovnikov , I believe after the fix is applied - this could be approved.
| f"{e} Run `connectors login` first, or make sure that the config is either present at the default location ({CONFIG_FILE_PATH}) or it's passed via the '-c' or '--config' option." | ||
| ) | ||
| self.ctx.exit(1) | ||
|
|
There was a problem hiding this comment.
| if self.value is None: | |
| msg = f"{CONFIG_FILE_PATH} is empty or invalid. Run `connectors login` to (re)create it." | |
| raise click.ClickException(msg) | |
There was a problem hiding this comment.
Let's close this one and leave another PR that tries to address the same problem?
There was a problem hiding this comment.
This one actually fixes it, I tested it. The other one doesn't work.
@artem-shelkovnikov
There was a problem hiding this comment.
I'm happy to merge the one that addresses the issue - if it's this one then let's merge this one :)
Summary
Fixes the CLI help path so command-group and subcommand help can render before a local
.cli/config.ymlexists. The root CLI now stores a lazy config wrapper and only loads the config when a real command callback reads from it, which keeps help-only invocations from failing before Click can print usage.Normal command execution without a config still fails, but the message now points users at the expected first step:
connectors login.Testing
python3 -m py_compile app/connectors_service/connectors/connectors_cli.py app/connectors_service/tests/test_connectors_cli.pygit diff --checkjob --help,job list --help,job list <connector_id>, and a--helptoken used as an option valueI also tried
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest app/connectors_service/tests/test_connectors_cli.py -q, but local pytest could not start because this environment is missing theelasticsearchpackage required by the repo warning filters.Closes #3700