Skip to content

fix(metadata): tolerate absent/null jira, bugs, packages in JSONParser#214

Merged
mimi1vx merged 1 commit into
openSUSE:mainfrom
plusky:fix/jsonparser-missing-keys
Jun 23, 2026
Merged

fix(metadata): tolerate absent/null jira, bugs, packages in JSONParser#214
mimi1vx merged 1 commit into
openSUSE:mainfrom
plusky:fix/jsonparser-missing-keys

Conversation

@plusky

@plusky plusky commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

JSONParser.parse iterated three metadata keys with no default:

for i in data.get("jira"): ...
for i in data.get("bugs"): ...
for prod, pkgvers in data.get("packages").items(): ...

If any key is absent (or explicitly null), .get() returns None and the
loop / .items() raises TypeError, aborting the whole parse. The current
metadata.json contract always carries these keys, so it doesn't fire today — but
a partial or malformed blob shouldn't crash the parser, and the sibling line
already does the right thing (data.get("repositories", [])).

Fix

data.get("jira") or [], data.get("bugs") or [], and
(data.get("packages") or {}).items() (handles both missing and null).

Test

test_json_parser_parse_tolerates_missing_optional_keys parses a minimal blob
(keys absent, packages null) and asserts empty results. Verified it fails on
the old code (TypeError) and passes on the fix.

Gates: ruff format/check clean, ty clean, pytest green.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.43%. Comparing base (d591e8f) to head (cbf19a6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #214   +/-   ##
=======================================
  Coverage   86.43%   86.43%           
=======================================
  Files         159      159           
  Lines        8832     8832           
=======================================
  Hits         7634     7634           
  Misses       1198     1198           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@plusky plusky force-pushed the fix/jsonparser-missing-keys branch 3 times, most recently from b39fe96 to b022034 Compare June 23, 2026 08:44
JSONParser.parse iterated data.get("jira"), data.get("bugs") and
data.get("packages").items() with no default, so a metadata blob missing any of
those keys (or carrying an explicit null) raised TypeError and aborted the parse.
Fall back to empty (or [] / {}), matching the existing data.get("repositories",
[]) handling.
@mimi1vx mimi1vx force-pushed the fix/jsonparser-missing-keys branch from b022034 to cbf19a6 Compare June 23, 2026 10:04
@mimi1vx mimi1vx merged commit af6ceb2 into openSUSE:main Jun 23, 2026
4 checks passed
@plusky plusky deleted the fix/jsonparser-missing-keys branch June 23, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants