[WRONG BRANCH] fix: back up non-object config values instead of repairing - #207
[WRONG BRANCH] fix: back up non-object config values instead of repairing#207luvs01 wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Comment |
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ddcaf7c7ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) { | ||
| warnAndBackupInvalidConfig(configPath, result.error); | ||
| return getDefaultConfig(); |
There was a problem hiding this comment.
Reject arrays in the shared diagnostics path
When config.json contains a top-level array and a diagnostics-based operation runs before loadConfig()—for example, ocx config set or mutatePersistedConfig()—configDiagnosticsFromRaw() still passes the array to mergeConfigDefaults(), which spreads it over defaults and returns source: "file" with no error. The operation can then overwrite the malformed original with defaults without creating the backup this guard promises, and config admission can incorrectly authorize writes from it. Apply the same non-null, non-array object check in the shared diagnostics/merge path and add coverage through readConfigDiagnostics().
Useful? React with 👍 / 👎.
⏳ DRAFT
What to do
Its title has been prefixed with |
Motivation
null) into defaults and thereby manufacture a seemingly-valid config that bypasses the invalid-file backup path and risks overwriting the original malformed file on startup. This change prevents silent data-loss by ensuring only plain objects are repairable.Description
loadConfig()to require a non-null, non-array object before attempting the merge-repair path and, if not an object, callwarnAndBackupInvalidConfig()and returngetDefaultConfig()instead of repairing.tests/config.test.tsthat write top-levelnumber,boolean,string,array, andnullJSON values and assert the file is backed up and defaults are returned.src/config.tsandtests/config.test.ts.Testing
bun test tests/config.test.tsand the updated config tests passed successfully.bun run typecheckwhich completed without errors andbun run privacy:scanwhich passed.bun run test; the run progressed but the GUI build step attempted external package downloads and failed in this environment (HTTP 403 to the registry), so the full suite could not complete here though the focused config tests passed.Codex Task