Repository navigation
feat(config): type secrets as such and read config from several files - #857
Merged
Merged
Conversation
Dipper read its whole configuration from 1 JSON file, so every secret had to sit next to settings that are not secret, and the file could then only be kept as a secret, out of review. And the secret fields were typed unevenly: the RPC provider URLs, which carry API keys, and the Kafka password were plain values, and serde quoted a secret it could not read in the error, which ends up in a log. Secrets are now known by type: - `Hidden<T>` leaves a value it cannot deserialise out of the error, as does the signer key's hex adapter, and the Kafka `sasl_password`s become `Hidden<String>`. - `SecretUrl`, for `chain_client.providers` and `alerts.slack_webhook_url`, shows a URL with its scheme, host, port and the shape of its path, masking the user and password, query values, the fragment and every path segment but a version such as `v2`, with a short fingerprint when anything was masked: `https://mainnet.infura.io/v3/*** (fingerprint e1d789)`. A key can look like any word, so dipper does not guess which segment holds it; the fingerprint tells 2 keys apart. A URL that fails to parse is left out of the error. The config now comes from every file on the command line, merged in order: objects key by key, anything else replaced by the later file. The merged result is read once, so an unknown field is refused wherever it came from, and an error names the field (`db.password: ...`); a single file still reports its line and column. Secrets can stay inline in 1 file, as a test setup wants, or go in a later `secrets.json` that holds only the secret fields, kept in a Secret, so the ConfigMap holds none and can be reviewed. The READMEs and the manifest describe both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ngs out of errors - A single config file is now read to its end: anything after the configuration, such as a stray `}` that closed it early and left later sections unread, is refused, as `serde_json::from_str` did before. - With several files, a key given twice in 1 object of a file is refused, as it is with 1 file, instead of the last one being used without a word. Later files still merge into earlier ones. - An error about a field no longer repeats a string it held, whatever the field: a provider URL with its key given where a list belongs, or a signing key where the signer's section belongs, used to be quoted in full. - The URL fingerprint's doc no longer claims it can't help guess a weak password. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cjorge-thegraph
marked this pull request as ready for review
November 23, 2026 20:16
cjorge-thegraph
added a commit
that referenced
this pull request
Nov 23, 2026
The writer fence's tests start their Postgres on its Unix socket only, as #861 does for the rest, and the registry's test databases keep the operator session and the writer pool on top of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MoonBoi9001
pushed a commit
that referenced
this pull request
Nov 23, 2026
🤖 I have created a release *beep* *boop* --- ## [0.3.4](v0.3.3...v0.3.4) (2026-11-23) ### Added * **config:** type secrets as such and read config from several files ([#857](#857)) ([fe92407](fe92407)) * **db:** connect to Postgres over TLS ([#847](#847)) ([2673181](2673181)) * **db:** let only 1 dipper process write, enforced by the database ([#858](#858)) ([6f88900](6f88900)) * **db:** make the database password optional ([#850](#850)) ([cb5d3b1](cb5d3b1)) * **metrics:** serve Prometheus metrics and optionally log as JSON ([#851](#851)) ([523819e](523819e)) * **rpc:** expose effective indexing targets and chain identity ([#860](#860)) ([aafc0ce](aafc0ce)) * **startup:** wait for Postgres and IISA instead of exiting ([#849](#849)) ([d1406d4](d1406d4)) ### Fixed * **db:** sslmode=verify-ca skips the hostname check, as libpq does ([#859](#859)) ([5fec97d](5fec97d)) * **k8s:** roll dipper out one pod at a time ([#846](#846)) ([de57e46](de57e46)) * **shutdown:** stop taking jobs first and fit the teardown in its budget ([#854](#854)) ([a1bc47d](a1bc47d)) ### Tests * run each test's Postgres on its Unix socket only ([#861](#861)) ([bc9e2b2](bc9e2b2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #848. Instead of
_filereferences andDIPPER__environment overrides, dipper now knows which fields are secrets by their type, and its configuration can come from several files merged in order.The problem: dipper read its whole configuration from 1 JSON file, so every secret sat next to settings that are not secret. The file could then only be kept as a secret, out of review. The secret fields were also typed unevenly:
Urls, and the Kafkasasl_passwordwas a plainStringwith hand-written redaction.invalid type: string "hunter2-secret", expected u32.Secrets known by type
Hidden<T>(dipper-core) leaves a value it can't deserialise out of the error, and so does the signer key's hex adapter. The error keeps its position.sasl_passwords in dipper-producer are nowHidden<String>. dipper-producer depends on dipper-core for this; it already depended onthegraph-core.SecretUrl(new) is used forchain_client.providersandalerts.slack_webhook_url.v2.https://mainnet.infura.io/v3/*** (fingerprint e1d789). 2 log lines can then be told to use the same key or not, without showing it./v2/rpc-key), so dipper doesn't guess which segment holds it; the fingerprint is what tells keys apart.ChainClientConfig::provider_urls()exposes the real URLs for connecting.Config from several files
dipper-service config.json [secrets.json ...]. Every argument is a file, merged in order: objects key by key, anything else (a string, a number, a list,null) replaced by the later file.deny_unknown_fieldsstill refuses a misspelt field in any file.}that closes the configuration early is refused rather than leaving the later sections unread. A key given twice in 1 object of a file is refused, with 1 file or several.serde_path_to_error(db.password: …), and leave out any string the field held. A secret given in the wrong shape, such as a provider URL with its key where the list of providers belongs, is not quoted either. A single file still reports its line and column.config.jsonfree of secrets in the ConfigMap, reviewable in git, and adds asecrets.jsonholding only the secret fields. That file lives in a Secret, for example one External Secrets renders from the secret store.k8s/README.mdshows the shape ofsecrets.jsonand the extra mount andargs. It notes that a list (chain_client.providers) is replaced whole, and that a changed secret needs a restart. The main README lists the secret fields.Dropped from #848
_filereferencesDIPPER__environment overridesThat removes the review's findings on #848: ambiguous types, values in errors, map defaults wiped by an override, unreachable list items, and the UTF-8 panic.
Not done: a startup warning when a secret field sits inline in the 1st file while a 2nd is given, which would catch a secret committed to the ConfigMap. It is easy to add if wanted.
Tests
a_rejected_secret_is_left_out_of_the_error(dipper-core) failed onmainwith the quoted value above, and passes now.SecretUrl: hosted RPC URLs (Alchemy, Infura, Ankr, QuickNode), a word-like key, Slack, user-info, query and fragment, a URL with nothing to mask, fingerprints,Debug/Display, and rejected values.db.passwordandalerts.slack_webhook_urlwithout their values;rpc-keyin the output. The webhook test now checks that the host shows with the path masked.main(sqlx 0.9, Rust 1.94):cargo +nightly fmt,cargo clippy --workspace --all-targets --all-features -D warningsandcargo nextest run --all-features(1,284 tests) pass locally.🤖 Generated with Claude Code