scripts: harden meta_to_xml.ps1 null head, limit guard and atomic XML write #1801
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1801
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/meta-to-xml-safety"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: META-TO-XML-NULL-HEAD-CASE-AND-LIMIT-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162168340)
What and why
scripts/meta_to_xml.ps1againstbink2or malformedindex.jsonentries whoseheadis null/absent ($_.head -is [string]) instead of throwingInvokeMethodOnNullon.StartsWith(...).5053494e/52424630hex prefixes case-insensitively (OrdinalIgnoreCase) in both filtering and$kindclassification.-Limitvalues upfront (throw "-Limit must be 0 or greater.") instead of writing an emptyfailures.txtand exiting0..tmpfile beside the destination and publish viaMove-Item -LiteralPath ... -Forcewithfinallycleanup.tests/test_meta_to_xml_paths.py.Tested
python -I tests/test_meta_to_xml_paths.py -v(live Windows PowerShell 5.1) ->Ran 3 tests in 4.548s,OK(verified in a detachedupstream/mainworktree that both new tests fail before the fix:FAILED (failures=2)).python -I tests/test_ci_registration.py->Ran 16 tests in 4.507s,OK.python -I tests/test_text_write_line_endings.py->Ran 3 tests in 12.931s,OK.python -I scripts/check_no_game_data.py scripts/meta_to_xml.ps1 tests/test_meta_to_xml_paths.py-> exit0.python -I -m compileall -q tests/test_meta_to_xml_paths.pyandgit diff --check-> clean.GPUs tested: n/a (Windows PowerShell 5.1 + stdlib Python tests on Windows 11 x64)
AI-assisted: yes
Checklist
needs rebase).Reviewed 4ef1614: compileall is clean on PR and main; the PowerShell tests are Windows-only and skip on this Linux host, so I reviewed the script change by reading it. All three hardenings look right (null-head rows skipped, case-insensitive head match, negative -Limit throws before creating Out, tmp+Move write with finally cleanup), and both new tests would fail on main by analysis. One thing to watch in CI: the bracket-path test now exercises Move-Item with brackets in the destination path - worth confirming that job stays green. Nothing was run dynamically.
AI-assisted review.
Recommendation: Merge
Red/green: On main test_meta_to_xml_paths.py has 2 failures (a null head row crashes Where-Object, a negative limit is accepted), and with the PR all 3 tests pass on Windows 11 at OreoFR's (RTX 4070).
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
Verified by OreoFR
3408969a7+ PR head4ef161444python -I tests/test_meta_to_xml_paths.pyAI-assisted (Claude Code, Claude Opus 5.5).