Skip to content

fix: handle non-dict parsed JSON in firmware version manifest parser#1355

Merged
michael-balint merged 1 commit into
masterfrom
dholt/fix-parse-manifest-typeerror-6394703
Jul 2, 2026
Merged

fix: handle non-dict parsed JSON in firmware version manifest parser#1355
michael-balint merged 1 commit into
masterfrom
dholt/fix-parse-manifest-typeerror-6394703

Conversation

@dholt

@dholt dholt commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • roles/nvidia-dgx-firmware/files/parse_manifest.py parse_versioning keeps the last json.loads-parseable line from the firmware container output, then indexes it with a string key (manifest_json['ErrorWritingVersioning']).
  • If that last parseable line decodes to a non-dict (e.g. a JSON array), the string-key index raises TypeError. Only KeyError was caught, so the exception escaped and aborted the task.
  • Guard that the parsed value is a dict before indexing; a non-dict now falls through to the existing "No JSON could be loaded" path and exits 1 cleanly instead of crashing.

Validation

  • git diff --check origin/master...HEAD
  • py_compile of the changed script
  • Reproduced the crash before the fix (non-dict last line → uncaught TypeError) and confirmed the clean exit 1 after the fix.
  • Added a self-contained regression test and ran it:
    python -m unittest discover -s roles/nvidia-dgx-firmware/tests -vRan 1 test ... OK
  • Public sanitizer pass on the PR body and added diff lines.

Notes

  • Behavior is unchanged for well-formed manifests; this only hardens the parser against malformed/non-dict input.
  • No pre-existing tests covered this script/role; the new test uses only the standard library and a tempfile, no external fixtures.

@dholt dholt requested a review from michael-balint July 1, 2026 02:53
Comment thread roles/nvidia-dgx-firmware/files/parse_manifest.py Fixed
Comment thread roles/nvidia-dgx-firmware/files/parse_manifest.py Fixed
parse_versioning kept the last json.loads-parseable line and then indexed it
with a string key. When that line parsed to a non-dict (e.g. a JSON array),
the index raised an uncaught TypeError because only KeyError was handled,
aborting the task. Guard that the parsed value is a dict before indexing and
fall through to the existing 'no JSON could be loaded' path otherwise. Adds a
regression test covering the non-dict input case.
@dholt dholt force-pushed the dholt/fix-parse-manifest-typeerror-6394703 branch from aad66bf to 2e08909 Compare July 1, 2026 03:05
@dholt

dholt commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@michael-balint Gentle ping on this one when you have a moment — it's a small, self-contained robustness fix for parse_manifest.py with a stdlib-only regression test. All 31 checks are green and it's mergeable. Thanks!

@michael-balint michael-balint merged commit 7821567 into master Jul 2, 2026
31 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