Repository navigation
fix(config): compare env-backed config regardless of JSONB key order - #575
Merged
Merged
Conversation
JSONB does not keep key order, so JSON.stringify called object values changed on every boot: the row was rewritten and a warning said an admin change was being reverted.
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.
Problem
bootstrapSystemConfigcompared the stored value and the env value withJSON.stringify. JSONB does not keep key order, so object values looked changed on every boot. In RoxTarget productionlockout_policy,authenticator_policyandflow_rate_limitslog "Overwriting system_config" on each of the boots in the 30 days of logs, which tells an operator an admin change may be being reverted when nothing changed. The row is also rewritten each time.Change
Compare with
isDeepStrictEqual, which ignores key order. A real difference still overwrites and warns.Testing
New unit test with reordered keys. Config unit tests, typecheck, ESLint and Prettier pass. The root cause in production is inferred from JSONB's documented ordering and from which keys warn. It was not checked against the stored rows.