Skip to content

Update: round-trip withOverrides config and redact secrets in diffs#10

Merged
taylortom merged 1 commit into
masterfrom
config-roundtrip-withoverrides
Jul 8, 2026
Merged

Update: round-trip withOverrides config and redact secrets in diffs#10
taylortom merged 1 commit into
masterfrom
config-roundtrip-withoverrides

Conversation

@taylortom

Copy link
Copy Markdown
Contributor

Update

Config migrations previously imported each conf/*.config.js default export and rewrote it as flat JSON.stringify(...). For an instance using the withOverrides({...}) baseline pattern that export is the fully merged object, so the rewrite inlined every inherited default and dropped the wrapper (and would break the baseline defaults.config.js itself). In read-only/dry-run modes the diff also printed raw secret values.

This makes the engine round-trip both config styles and stop leaking secrets:

  • withOverrides round-trip — each file is classified via non-enumerable Symbol.for('adapt-authoring:configOverrides'/'…configDefaults') markers a withOverrides helper attaches. Overrides files transform the authored overrides only and re-emit export default withOverrides({...}); the baseline is skipped (hand-maintained per release); plain object exports keep their existing behaviour.
  • Secret redactionlogConfigDiff masks sensitive leaf keys (secret/password/token/apiKey/connectionUri/…) as [redacted], recursively into nested values, with an additive redactKeys config option.
  • Read-only auto-detection — a non-writable conf dir (pre-flight W_OK check, plus a defensive catch of EACCES/EROFS/EPERM on write) degrades to the report-only path automatically. readOnlyConfig remains as an override for writable-but-hands-off (version-controlled) conf.

Fix

  • Preserve key: undefined entries (used to unset an inherited default) by emitting valid JS instead of JSON, which dropped them.
  • Compose multiple config migrations on the same file within one boot via a per-run working-copy cache (previously a second migration overwrote the first).
  • mutate(fn) receives a second context.merged arg (read baseline values on overrides installs); a null-unsafe mutate is now a per-file warning rather than a boot failure.

Docs

  • New "withOverrides round-trip", secret-redaction, and auto-detection sections in docs/migrations.md.
  • Corrected the "Restart required" description — no such error is thrown; config file changes take effect on the next restart.

Testing

  • 119 unit/integration tests pass (node --test), standard clean.
  • Verified end-to-end against real config: withOverrides write round-trip (wrapper kept, defaults not inlined, baseline untouched), full runMigrations() against an isolated DB, secret redaction, and a real read-only (chmod 0555) conf dir degrading to report-only.

Config migrations now transform the authored overrides of a withOverrides({...}) file and re-emit the wrapper (instead of flattening it to JSON and inlining defaults); plain object exports are unchanged and the baseline is skipped. Secrets are redacted in read-only/dry-run diffs, undefined-valued keys are preserved, multiple config migrations compose on one file, mutate() gets a context.merged arg, and a non-writable conf dir auto-degrades to report-only.
@taylortom
taylortom merged commit dd667c5 into master Jul 8, 2026
3 checks passed
@taylortom
taylortom deleted the config-roundtrip-withoverrides branch July 8, 2026 16:15
github-actions Bot pushed a commit that referenced this pull request Jul 8, 2026
# [2.1.0](v2.0.0...v2.1.0) (2026-07-08)

### Chore

* trigger add-to-project on reopened issues and PRs ([cd2ee80](cd2ee80))

### Docs

* Add README ([5c86395](5c86395))
* document dry-run mode and readOnlyConfig ([8b62995](8b62995))
* file the migrations guide under the development section (#8) ([036239f](036239f)), closes [#8](#8)
* note DDL/transaction limitation on replica sets ([56708b1](56708b1))

### Update

* round-trip withOverrides config and redact secrets in diffs (#10) ([dd667c5](dd667c5)), closes [#10](#10)
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

1 participant