Skip to content

Report damaged local state encoding through the installed CLI error contract - #733

Closed
rudycelekli wants to merge 2 commits into
ktwu01:mainfrom
rudycelekli:fix/local-state-encoding-errors
Closed

rudycelekli wants to merge 2 commits into
ktwu01:mainfrom
rudycelekli:fix/local-state-encoding-errors

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

A damaged UTF-8 state.json raises UnicodeDecodeError outside the installed client's DataSyncError boundary. Both offline search and sync can then raise a traceback instead of returning the documented structured local-state error.

Classify encoding failures alongside other unreadable/invalid state files as invalid_local_state. Preserve the original file and the existing error status/exit contract; no update or repair is performed automatically.

Validation: all three new regressions fail on unchanged f056cb9. Real invalid bytes exercise DataStore.state, installed sync --json, and installed search --json; after the fix, the CLI emits the structured error on stderr and leaves bytes unchanged. New regressions plus data-sync suite: 23 passed. No network fallback is used.

Full required CI sequence passed on an independent clean detached checkout, with recursive submodule initialization: Ruff check, Ruff format check, normalize-catalog, classify, build-data-release, and pytest (1,468 passed). This is the installed state-file boundary, separate from #722's catalog/index/shard decoding and #728's interrupted remote transfers. No source data or generated artifacts are changed.

Prepared with Codex (GPT) assistance. Hosted CI remains pending.

@rudycelekli

Copy link
Copy Markdown
Contributor Author

330226 GPT — AI assistance was used to reproduce, implement, and test this change. Damaged UTF-8 local state now uses the existing JSON error contract; focused tests and the complete required CI sequence passed locally.

ktwu01 commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Hi @rudycelekli, thanks, adding UnicodeDecodeError to that except is the right fix. One trim request: please move tests/test_local_state_encoding.py into tests/test_data_sync.py, where the malformed-JSON invalid_local_state contract is already tested. The two cases read best side by side, and could even be one parametrized test (b"{not json" / b"\xff"). (Same pattern as noted on #749.)


Generated by Claude Code

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
@rudycelekli
rudycelekli force-pushed the fix/local-state-encoding-errors branch from ab950ba to 73b29da Compare October 3, 2026 11:25
@rudycelekli

Copy link
Copy Markdown
Contributor Author

Moved the regression coverage into tests/test_data_sync.py, preserving every moved test/helper AST and the production fix. Rebased onto current main 3547a5c and reran all six required clean-checkout stages, including recursive submodules: all passed (1,635 tests). Updated head: 73b29da5764c32356ac8abd26bd88cf5254bfaae. Hosted checks are pending on that head.

330226 GPT-6 — OpenAI Codex assisted this repair; the test and generator results above were executed.

ktwu01 commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Closing as not planned. One author now has a cap of 10 open issues + PRs, and this account had 56 open PRs and 11 open issues, mostly paired with each other. We merged the three changes that fix silent data loss in the corpus (#723, #774, and #773 once rebased) and are closing the rest so review stays possible.

This is not a verdict that the change is wrong. If you think this one matters, reopen it later when you are under the cap, one at a time, with a reproduction from a real user or caller rather than a hypothetical edge case.

不是否定这个改动本身。为保证评审能跟上,同一作者最多同时保留 10 个未关闭的 issue/PR;该账号曾有 56 个未关闭 PR 和 11 个 issue。已合并修复语料静默丢失的三个改动,其余先关闭。若认为本条重要,请在低于上限后逐个重新打开,并附真实用户或调用方的复现。


Generated by Claude Code

@ktwu01 ktwu01 closed this Oct 7, 2026
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