fix(chunk): read connection secrets from the environment

What

Chunk mode reads its Gitaly configuration from GITALY_CONNECTION_INFO and the adapter connection from CHUNK_CONNECTION_INFO, as advanced mode does. The flags remain as a fallback. Command-line arguments are readable by other local users, so secrets now travel in the environment. The indexer's error output reaches Rails logs and stored errors, so it no longer logs raw options or connection URLs, and it escapes the PostgreSQL password so a parse error cannot echo it.

flowchart LR
    caller[Caller] --> env[Environment variables]
    caller --> flags[Command-line flags]
    env -->|"replaces the flag<br/>Gitaly: overrides set fields"| cfg[Chunk configuration]
    flags -->|fallback| cfg
    cfg --> op[Index or delete]
    op -.->|never logged| logs[Logs]

Confidential, details are kept there: https://gitlab.com/gitlab-org/gitlab/-/work_items/639629

The Rails MR sends the new variables, so it needs this release.

Testing

  • Seven cases: the Gitaly token, PostgreSQL password (2 forms), OpenSearch AWS key (2 forms), Elasticsearch URL credentials (2 forms). The command line held the secret in 0 of 7 and the environment in 7 of 7.
  • Debug logs held the secret in 0 of 7.
  • A second local user read the command line, with no secret in it, and could not read the environment.
  • make test with the Docker integration tests passed (41 packages ok, 0 failures). The chunk package ran 177 tests with 0 skipped. golangci-lint v2.11.3 reported 0 issues.

Performance

No change. The environment is read once at startup.

Agent context
  • Touches internal/mode/chunk, the three adapter clients, and the README.
  • Residual: the process owner and root can still read the environment. The indexer started no child process after launch in any of the 7 cases.
  • Rails with the unpatched binary failed 4 of 4 Elasticsearch examples, so the two move together. Unpatched Rails with this binary ran the integration spec, 12 examples with 0 failures on all three adapters, through the flag fallback.

An AI coding assistant wrote this change. The assistant also checked each claim against the indexer sources and the Rails code it cites and ran golangci-lint v2.11.3 and the full test suite, including the integration tests, on a test VM. The assistant also ran the built indexer and the Rails specs on a test VM.

Merge request reports

Loading
Loading