Skip to content

gamedata_graph: keep scanning after an unsupported XML encoding - #6765

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Solthodox:fix/gamedata-graph-unknown-encoding
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Solthodox:fix/gamedata-graph-unknown-encoding

Conversation

@Solthodox

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: GAMEDATA-GRAPH-UNKNOWN-ENCODING.

What and why

An unknown XML codec raises LookupError, not ParseError. One such payload previously aborted graph construction even when its neighbors could be parsed. Classify this document as unparsed using the usual root hint, without creating edges or discarding other documents.

Merge trials were clean against main, #2984, #5526 and #6551. #4090 and #4509 already conflict with main; their conflict hunks are unchanged with this patch.

Tested

Linux x86-64, Python 3.12.13, CPU only; no GPU or driver used.

  • One invented unknown-encoding document and one valid XML document: main exited 1 with LookupError; patched CLI exited 0 with two payloads (one parsed, one unparsed).
  • python3.12 -I tests/test_gamedata_graph.py (19 passed); python3.12 -I tests/test_gamedata_graph_bad_index.py (5 passed).
  • git diff --check and python3.12 -I scripts/check_no_game_data.py on the changed files passed.

AI-assisted: yes (Codex).

Checklist

  • No game data, keys or decryption, including in examples or logs. All fixtures are authored.
  • New translator rule documented: not applicable; no translator changes.

Handle codec lookup failure at the document boundary, preserving the hinted root and all other payloads.
@Sqoutv

Sqoutv commented Nov 23, 2026

Copy link
Copy Markdown

Tested 82a009a on Linux (Ubuntu 24.04.5 LTS, x86_64, Python 3.12.16, CPU-only, no game files): pass.

Commands run:

  • python3 -m compileall -q make_game.py tools tests (pass)
  • python3 -I tests/test_gamedata_graph.py -v (19/19 passed)
  • python3 -I tests/test_gamedata_graph_bad_index.py -v (5/5 passed)
  • python3 -I tests/test_gamedata_xml.py -v (13/13 passed)
  • python3 -I tests/test_docs_links.py, test_docs_repo_paths.py, test_docs_repeated_lines.py, test_docs_cli_flags.py, test_docs_list_items.py (all passed)
  • python3 -I scripts/check_no_game_data.py docs/gamedata_graph.md tests/test_gamedata_graph.py tools/gamedata_graph.py and git diff --check (pass)
  • python3 -I tests/test_text_write_line_endings.py failed only on pre-existing tools/f64_omod_probe.py:268 on main; the files touched by this PR (tools/gamedata_graph.py, tests/test_gamedata_graph.py) have 0 violations.

Code review notes:

  • Catching LookupError alongside (ET.ParseError, ValueError) in tools/gamedata_graph.py matches tools/gamedata_xml.py and tools/gamedata_reader.py.
  • Spot-checked additional unsupported/non-text XML encodings (base64, hex, zlib, rot_13, utf-7, shift_jis, idna, punycode) and carve-mode mixed valid/unknown-encoding payloads; all classified as unparsed without aborting or leaking edges.
  • Stdlib-only under python -I, synthetic fixtures only, no game data.

(AI-assisted review)

@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.

Summary

tools/gamedata_graph.py scan_document() now catches LookupError when parsing XML and caches doc["data"] locally, treating an unsupported encoding as an unparsed payload rather than aborting. A test with an unknown-encoding document beside a valid one checks the summary counts, and the docs record the behavior.

Why merge

A single XML file declaring an unknown codec should not stop the whole graph build; it now contributes no edges but leaves other documents intact. This makes the graph tool robust on mixed-encoding carves.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

tools/gamedata_graph.py scan_document() now catches LookupError when parsing XML and caches doc["data"] locally, treating an unsupported encoding as an unparsed payload rather than aborting. A test with an unknown-encoding document beside a valid one checks the summary counts, and the docs record the behavior.

Why merge

A single XML file declaring an unknown codec should not stop the whole graph build; it now contributes no edges but leaves other documents intact. This makes the graph tool robust on mixed-encoding carves.

Verdict: Approve

@shayderrr
shayderrr merged commit c2d7dea into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
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