Skip to content

REPL.2 — Connection config precedence: CLI flag > env var > config file > default - #165

Draft
fupelaqu wants to merge 3 commits into
mainfrom
feature/REPL.2
Draft

REPL.2 — Connection config precedence: CLI flag > env var > config file > default#165
fupelaqu wants to merge 3 commits into
mainfrom
feature/REPL.2

Conversation

@fupelaqu

@fupelaqu fupelaqu commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Implements story REPL.2 (epic REPL — REPL Hardening). Closes #162.

What

Fixes the three verified defects that made the documented configuration surface dead:

  • (a) CLI defaults always beat the configCliConfig now builds a layered Typesafe chain: CLI layer (ONLY flags actually passed, via ConfigValueFactory — also kills the HOCON-injection bug for passwords containing "/\) > explicit env layer > ConfigFactory.load() > builtin softnetwork-elastic.conf defaults tail, plus a sanitize guard for empty/null scheme/host/port.
  • (b) conf/application.conf never loaded — the external layer is the no-arg ConfigFactory.load(), the only variant that honours the launcher's -Dconfig.file.
  • (c) Credentials never authenticated — the builtin method = "noauth" default is deleted; ElasticCredentials auto-detection (api-key > bearer > basic > none) now engages. Release note: library-visible for ElasticConfig consumers — configs that supply credentials without an explicit method now actually authenticate.

Also: parseArgs/printUsage moved from object Cli extends App (delayedInit-untestable) to the CliConfig companion; empty env var ≡ unset (JVM filter + launcher unset loop incl. the ELASTIC_WATCHER_* family); credential env values verbatim, coordinates trimmed; ELASTIC_IP > ELASTIC_HOST and ELASTIC_<X> > ELASTIC_CREDENTIALS_<X> alias precedence; repl.md precedence docs.

Verification

  • NEW CliConfigSpec: 12-test precedence matrix through a two-parameter test seam (no JVM-global config.file/invalidateCaches mutation — root-scoped parallelExecution makes a sysprop bracket a cross-suite race).
  • core/test: 617/617 green; cross-compile 2.12.20 + 2.13.16; scalafmt + headerCheck green.
  • Manual smoke on a published-style install (launcher rendered by the updated install.sh, Docker ES 8.18.3 on :19200): env var connects, file connects, -p wins over conflicting env+file, all-unset dials localhost:9200, ELASTIC_HOST="" treated as unset.
  • Adversarial review (Blind Hunter + Acceptance Auditor + edge-case pass): PASS, 0 unresolved HIGH/MED; ecosystem-wide grep confirms no consumer reads elastic.credentials.method unguarded.

Version bumped 0.20.1 → 0.20.2-SNAPSHOT.

🤖 Generated with Claude Code

Part of epic #169 (REPL Hardening). Follow-up spun off during review: #172 (watcher block dotted-path literals — outside this PR's sanitize coverage).

… file > default

- CliConfig: layered Typesafe chain (only passed flags in the primary layer via
  ConfigValueFactory; explicit env layer with empty-equals-unset filtering; no-arg
  ConfigFactory.load() so -Dconfig.file works; builtin softnetwork-elastic.conf
  as defaults tail) + sanitize guard for empty/null scheme/host/port
- parseArgs/printUsage moved from Cli (App/delayedInit untestable) to the
  CliConfig companion; usage text documents the precedence
- softnetwork-elastic.conf: drop 'method = "noauth"' so supplied credentials
  auto-detect their auth method (api-key > bearer > basic > none) - previously
  -u/-P/ELASTIC_USERNAME/... produced an UNAUTHENTICATED client
- install.sh: launcher unsets empty ELASTIC_*/ELASTIC_WATCHER_* env vars
  (HOCON ${?VAR} treats empty as present); conf template documents precedence
- NEW CliConfigSpec: 12-test precedence matrix through the two-parameter
  buildElasticConfig(env, external) seam - no JVM-global sysprop mutation
- docs: repl.md gains a Configuration Precedence section

Release note: library-visible change for ElasticConfig consumers - configs that
supply credentials without an explicit 'method' now authenticate (auto-detect)
instead of silently sending no Authorization header.

Closed Issue #162

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fupelaqu and others added 2 commits July 30, 2026 16:36
#162)

Follow-up to PR #165 CI: since the builtin conf no longer forces
method = "noauth", an unauthenticated setup resolves authMethod to None
and JestClientCompanion.buildHttpConfig fell into its catch-all
'Invalid authentication configuration' throw at client creation
(172 es6jest CI failures). None now behaves exactly like Some(NoAuth);
an explicitly selected method with missing credentials still fails loudly.

Audit of every authMethod matcher: es6rest/es7rest/es8java/es9java
companions and the Jest interceptor/factory already fall through to
no-auth - the Jest buildHttpConfig was the only gap.

Tests: JestClientCompanionSpec gains an embedded-ES regression case (CI);
NEW pure-JVM JestClientNoAuthSpec covers creation-time behaviour without
a server (embedded ES 6.8 cannot start on Apple Silicon: x86-only
-XX:UseAVX=2), 2/2 green locally under sbt17.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

REPL: environment variables AND conf/application.conf are both ignored — only CLI flags configure the connection

1 participant