Skip to content

fix(config): validate system_config on the runtime read path#67

Merged
Bccorb merged 1 commit into
mainfrom
fix/system-config-runtime-validation
Jul 6, 2026
Merged

fix(config): validate system_config on the runtime read path#67
Bccorb merged 1 commit into
mainfrom
fix/system-config-runtime-validation

Conversation

@Bccorb

@Bccorb Bccorb commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closes #13

Summary

getSystemConfig() trusted database rows with a cast and never validated them; only the admin read handler parsed against the schema. Invalid or malformed system_config could therefore flow straight into auth logic (token TTLs, roles, origins, login methods).

This validates on the runtime read path:

  • Parse loaded rows against SystemConfigSchema before caching.
  • Fail loudly on invalid config: the call throws and logs a descriptive error instead of returning malformed values (fail-closed).
  • Fix the cache TTL comment (300_000 ms is 5 minutes, not 30 seconds).

Behavior change

If stored system_config does not satisfy SystemConfigSchema, getSystemConfig() now throws instead of returning bad data. In normal operation this cannot happen: bootstrap seeds all required keys and the admin write path already validates. The change protects against out-of-band or corrupted rows.

Testing

  • Unit tests updated to use full valid config fixtures (via buildSystemConfig) and to cover the new validation-failure path.
  • Full suite: 487 passed, 3 skipped. Typecheck + lint clean.

getSystemConfig() now parses stored rows against SystemConfigSchema on
load rather than casting them, and fails loudly on invalid config so
malformed values never reach auth logic. Correct the cache TTL comment
(the value is 5 minutes, not 30 seconds). Update the unit tests to use
full valid config fixtures and cover the validation-failure path.

Closes #13
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Bccorb Bccorb merged commit 6676910 into main Jul 6, 2026
2 of 3 checks passed
@Bccorb Bccorb deleted the fix/system-config-runtime-validation branch July 6, 2026 23:58
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.

[Feature]: Validate system_config in the runtime read path

2 participants