mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:20:53 +01:00
[PR #1438] glb_writer: harden JSON/transform/primitive validation and shared path guard (GLB-WRITER-VALIDATION-HARDENING) #1468
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1468
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1438
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/glb-writer-validation-hardening📝 Commits (1)
39d3dc4glb_writer: harden JSON/transform/primitive validation and shared path guard (GLB-WRITER-VALIDATION-HARDENING)📊 Changes
2 files changed (+148 additions, -17 deletions)
View changed files
📝
tests/test_glb_writer.py(+88 -0)📝
tools/glb_writer.py(+60 -17)📄 Description
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.