Skip to content

fix: Surface all config loading errors in preAction hook#124

Merged
JoshMock merged 2 commits into
mainfrom
MattDevy/fix/issue-97
Apr 13, 2026
Merged

fix: Surface all config loading errors in preAction hook#124
JoshMock merged 2 commits into
mainfrom
MattDevy/fix/issue-97

Conversation

@MattDevy
Copy link
Copy Markdown
Contributor

@MattDevy MattDevy commented Apr 13, 2026

Summary

  • The preAction hook previously only reported config errors when --config-file or --use-context were explicitly passed (else if), silently discarding failures in the common case
  • Commands would proceed without config and produce confusing downstream errors (e.g. missing_config from the transport layer) with exit code 0, or silently connect to localhost:9200
  • Changed else if (configPath != null || contextName != null) to else so all config loading failures write to stderr and exit 1
  • Added early return for the version command which does not require configuration

Closes #97
Closes #102

Test plan

  • New integration test: elastic es info in a config-free directory exits 1 with "No configuration file found" on stderr
  • New integration test: elastic es info --config-file /nonexistent exits 1 with error on stderr
  • Existing test: elastic version --json still succeeds without config
  • Full test suite passes (510 tests, 0 failures)
  • Manual verification: elastic es info in empty dir shows clean error (no silent fallback to localhost:9200)

The preAction hook previously only reported config errors when
--config-file or --use-context were explicitly passed, silently
discarding failures in the common case. Commands would proceed
without config and produce confusing downstream errors with exit 0.

Now all config loading failures write to stderr and exit 1. The
version command is exempt since it does not require configuration.
@MattDevy MattDevy requested a review from JoshMock April 13, 2026 11:33
@JoshMock JoshMock merged commit 4d10966 into main Apr 13, 2026
16 checks passed
@JoshMock JoshMock deleted the MattDevy/fix/issue-97 branch April 13, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No warning when running without any config file Config loading errors silently discarded in preAction hook

2 participants