Skip to content

fix: preserve invalid config before fallback - #26

Closed
0disoft wants to merge 1 commit into
lidge-jun:devfrom
0disoft:task/config-parse-recovery
Closed

fix: preserve invalid config before fallback#26
0disoft wants to merge 1 commit into
lidge-jun:devfrom
0disoft:task/config-parse-recovery

Conversation

@0disoft

@0disoft 0disoft commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • validate the minimum required config.json shape when loading opencodex config
  • preserve invalid config files by copying them to config.json.invalid-<timestamp> before falling back to defaults
  • warn the user once per process when the fallback path is used
  • honor OPENCODEX_HOME for config/pid paths so config behavior can be tested without touching the real home directory

Fixes #25

Verification

  • C:\Users\cherr\.bun-canary\bin\bun.exe test tests/config.test.ts
  • C:\Users\cherr\.bun-canary\bin\bun.exe run typecheck
  • C:\Users\cherr\.bun-canary\bin\bun.exe test tests

@0disoft
0disoft force-pushed the task/config-parse-recovery branch from f11e51c to 3f35c77 Compare June 24, 2026 02:44
lidge-jun added a commit that referenced this pull request Jun 25, 2026
Rebuilt on current dev from PR #26 by 0disoft / ZeroDi.

Co-authored-by: 0disoft <rodisoft1@gmail.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Thanks for the original fix. I rebuilt the intent on top of the current dev branch instead of merging this stale branch directly, because current dev has since added multi-auth credential generation/tombstone/refresh-lock hardening and this PR now conflicts with those files.

Landed on dev as:

  • 4d9d9f9 fix: preserve invalid config before fallback
  • Co-authored-by: 0disoft <rodisoft1@gmail.com>

What was preserved from this PR:

  • invalid config.json is copied to config.json.invalid-<timestamp> before fallback;
  • fallback logs a warning with the config path and reason;
  • warning/backup happens once per config path per process;
  • regression tests cover invalid JSON and invalid config shape.

What changed for current dev compatibility:

  • kept the existing dynamic OPENCODEX_HOME path helpers already present on dev;
  • did not touch src/codex-account-store.ts, preserving current generation/tombstone/CAS refresh hardening;
  • allowed existing port: 0 and providers: {} test/runtime contracts while still rejecting missing required shape and mismatched non-empty defaultProvider.

Verification:

  • local bun run typecheck: pass
  • local bun run privacy:scan: pass
  • local bun test tests: 356 pass / 0 fail
  • GitHub Cross-platform CI on dev run 28138885594: ubuntu + windows success

Closing this PR as superseded by the credited dev rebuild.

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.

2 participants