Skip to content

gamedata_blobs: a bad carve folder is one error line naming the index and the bad row - #5948

Merged
shayderrr merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/7-blobs-bad-index
Nov 23, 2026
Merged

shayderrr merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/7-blobs-bad-index

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Item: EGEN-BLOBS-BAD-INDEX (DeepSeek7)

tools/gamedata_blobs.py sent a folder target straight to gamedata_index.DirectorySource, which reads index["files"] and every row's off and stored without validation. A hand-edited or half-written carve folder therefore failed with error: 'files', error: 'stored' or error: [Errno 2] No such file or directory: '<dir>\index.json' — naming neither the index nor the bad row — and a missing file target printed the bare path (error: C:\...\x.rpf).

check_carve_index() now names what is wrong before the scan: the folder when there is no index.json, the index when the JSON does not parse, the missing 'files' list, and the row number when a row has no off or stored. A missing file target says no such file or folder. One error: line, exit 1, no traceback, which is what tests/test_gamedata_maps_bad_index.py already requires of gamedata_maps.py.

Test

python -I tests/test_gamedata_blobs.py

Negative control, with LEONIDA_GAMEDATA_BLOBS pointing at a copy of upstream/main's tools/gamedata_blobs.py (same sibling modules beside it):

LEONIDA_GAMEDATA_BLOBS=<copy of main's gamedata_blobs.py> python -I tests/test_gamedata_blobs.py
FAIL: test_index_without_files_names_the_key ... 'index.json' not found in "error: 'files'"
FAIL: test_malformed_json_names_the_index ... 'index.json' not found in 'error: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)'
FAIL: test_no_index_json_names_the_folder ... not found in "error: [Errno 2] No such file or directory: '<dir>\\index.json'"
FAIL: test_row_without_stored_names_the_row ... 'index.json' not found in "error: 'stored'"
FAIL: test_missing_file_names_what_is_wrong ... 'no such file or folder' not found in 'error: <dir>\\nope.rpf'
Ran 7 tests — FAILED (failures=5); the two existing tests pass on both trees

With this branch:

Ran 7 tests in 1.1s

OK

GPU

No GPU needed. Windows 11, Python 3.12, python -I; every fixture is a synthetic carve folder written by the test.

Notes

  • check_carve_index() is called in read_payloads() (library callers) and in main()'s directory branch: main reads the index rows for the --json overwrite guard before it calls read_payloads(), so a check only inside read_payloads() never ran for the CLI.
  • gamedata_sps1.py and psin_psch.py share the same DirectorySource and print the same bare errors; I left them alone to keep this to one tool.

AI-assisted.

…rror

A folder target went straight to DirectorySource, which reads index['files'] and each row's 'off' and 'stored' with no validation, so a hand-edited or half-written carve folder failed as 'error: files', 'error: stored' or a raw index.json path. check_carve_index() names the folder, the index and the offending row before the scan, and a missing file target now says so instead of printing the path alone.
… the index

Five synthetic bad targets: no index.json, malformed JSON, no 'files' list, a row without 'off'/'stored', and a missing file. Each must be one line, start with 'error:', name the index or the file and exit 1 with no traceback. LEONIDA_GAMEDATA_BLOBS points the suite at another copy for the negative control.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Reviewed change in PR #5948: gamedata_blobs: a bad carve folder is one error line naming the index and the bad row.

Scope: tests/test_gamedata_blobs.py, tools/gamedata_blobs.py
Diff: +77 / -2 across 2 file(s).

The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.

Reviewed by shayderrr via automated batch review.

@shayderrr

Copy link
Copy Markdown
Collaborator

Thanks @evilclanker9000 - I went through gamedata_blobs: a bad carve folder is one error line naming the index and the bad row and the diff around tests/test_gamedata_blobs.py. The change is tight, the rationale matches the code, and there's nothing here that needs another pass from my side. Approved and squash-merging it into main now. Nice work.

@shayderrr
shayderrr merged commit c6e56d9 into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
@memorypressure

Copy link
Copy Markdown

Post-merge correction to our earlier #6701 note, now that the blame is nailed down: main's red on tests/test_gamedata_blobs.py BadCarveIndexTest.test_missing_file_names_what_is_wrong comes from YOUR commit c6e56d9 — it added the test's "error:"/exit-1 expectation for a missing/bad target, which contradicts the repo-wide BUILD-1046 convention (#6701, tools print one ERROR line and exit 2) that gamedata_blobs.py correctly follows. Reproduced on current main dfe4e4a: the tool's ERROR:/2 vs the test's error:/1. The fix belongs on the test side (align to ERROR:/2) or an explicit documented carve-out — our #6701 comment pointed at the wrong commit. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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.

3 participants