Skip to content

fix(cli): allow help without config#4075

Open
nanookclaw wants to merge 2 commits into
elastic:mainfrom
nanookclaw:fix/cli-help-without-config
Open

fix(cli): allow help without config#4075
nanookclaw wants to merge 2 commits into
elastic:mainfrom
nanookclaw:fix/cli-help-without-config

Conversation

@nanookclaw

Copy link
Copy Markdown

Summary

Fixes the CLI help path so command-group and subcommand help can render before a local .cli/config.yml exists. 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.py
  • git diff --check
  • Stubbed Click-routing smoke check for job --help, job list --help, job list <connector_id>, and a --help token used as an option value

I 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 the elasticsearch package required by the repo warning filters.

Closes #3700

@nanookclaw nanookclaw requested a review from a team as a code owner June 15, 2026 20:32
@cla-checker-service

cla-checker-service Bot commented Jun 15, 2026

Copy link
Copy Markdown

💚 CLA has been signed

@artem-shelkovnikov

Copy link
Copy Markdown
Member

@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?

@nanookclaw

Copy link
Copy Markdown
Author

Completed the Elastic Contributor Agreement on 2026-06-15 as Nanook Claw using the commit author email nanook@agentmail.to, but the CLA status context is still failing on commit 46b21d2e.

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.

@artem-shelkovnikov

Copy link
Copy Markdown
Member

buildkite test this

@nanookclaw nanookclaw force-pushed the fix/cli-help-without-config branch from 46b21d2 to df88c86 Compare June 20, 2026 01:04
@nanookclaw

Copy link
Copy Markdown
Author

Rebased fix/cli-help-without-config onto current main and force-pushed head df88c86d.

Local verification:

  • python3 -m py_compile app/connectors_service/connectors/connectors_cli.py app/connectors_service/tests/test_connectors_cli.py
  • git diff --check

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest app/connectors_service/tests/test_connectors_cli.py -q still cannot collect in this local environment because the pytest warning filters import the missing elasticsearch package. Buildkite should now be testing the current branch.

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic self-requested a review July 2, 2026 13:11

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's close this one and leave another PR that tries to address the same problem?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one actually fixes it, I tested it. The other one doesn't work.
@artem-shelkovnikov

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm happy to merge the one that addresses the issue - if it's this one then let's merge this one :)

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.

connectors login required before connectors <command group> --help, but error message doesn't say so

3 participants