glb_writer: harden JSON/transform/primitive validation and shared path guard (GLB-WRITER-VALIDATION-HARDENING) #1438
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!1438
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/glb-writer-validation-hardening"
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
Item ID:
GLB-WRITER-VALIDATION-HARDENINGAI-assisted: yes
Summary
Fixes validation, numerical-stability, and CLI-safety bugs in
tools/glb_writer.py:read_glb_summary()strict JSON & buffer-index validation:NaN,Infinity,-Infinity) withGlbErrorviaparse_constant.RecursionErrorfrom deeply nested JSON intoGlbError("invalid JSON chunk: nesting is too deep")instead of leaking a raw traceback.bufferViews[i].buffervalues (previouslyFalse == 0slipped pastbv.get("buffer", 0) == 0).build_instanced_glb()transform validation and numerical stability:(3, 4, 3)tuple shapes and rejects non-numeric/boolean components withGlbErrorinstead of crashing with rawIndexError/ValueErroror emitting malformed node TRS arrays inmode="nodes".math.hypot(*q)for quaternion normalization so large finite quaternions (e.g.(1e200, 0, 0, 0)) do not overflowv * vtoinf.sc[0] * sc[1] * sc[2](which falsely underflowed valid tiny positive scales like(1e-120, 1e-120, 1e-120)to0.0).instance_bounds()outputs withGlbErrorinstead of emitting±infinstats["bounds"].pack_primitive(),_pack_indices(), and_parse_base_color_factor()validation:GlbError(instead of rawValueError: min() iterable argument is emptyorTypeError) on emptypositions/indicesor boolean/non-integer indices.base_color_factorentries withGlbError(consistent with_parse_alpha_mode).report_paths.same_report_path(args.in_obj, args.out_glb)and rejects existing directory outputs early withGlbError.0o600) before unlinking in_write_bytes_atomicerror cleanup so read-only targets clean up reliably on Windows.Verification (macOS Apple M5, arm64, Python 3.14; no game files)
python3 -m compileall -q make_game.py tools tests— OKpython3 -I scripts/check_no_game_data.py tools/glb_writer.py tests/test_glb_writer.py— OKpython3 -I tests/test_glb_writer.py— 74/74 OK (4 new test methods)tests/test_glb_atomic.py(12/12, 1 nt-only skip),tests/test_glb_writer_buffers.py(2/2),tests/test_glb_inspect.py(36/36, 1 skip),tests/test_glb_skinning.py(26/26),tests/test_batch_glb.py(16/16),tests/test_anim_glb.py(36/36),tests/test_skinned_glb.py(30/30) — all OKpython3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I tests/test_ci_registration.py— 16/16 OKtests/test_glb_writer.pyagainst unpatchedupstream/main1154976d4):Ran 74 tests — FAILED (failures=1, errors=2)— catchesNaNJSON acceptance, empty-index rawValueError, and large-quaternion/tiny-scale rejection.Red/green: the PR's tests fail on main 4938673 and pass on head 39d3dc489b09 (Linux, Python 3.13.18).
Targeted batch of 11 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)