Skip to content

Fix content list parsing when Pulp returns a bare JSON array from /api/v3/content/#90

Merged
jajreidy merged 1 commit intokonflux-ci:mainfrom
jajreidy:fix-build-id-search
Mar 26, 2026
Merged

Fix content list parsing when Pulp returns a bare JSON array from /api/v3/content/#90
jajreidy merged 1 commit intokonflux-ci:mainfrom
jajreidy:fix-build-id-search

Conversation

@jajreidy
Copy link
Copy Markdown
Contributor

What
Pulp’s generic content list endpoint can return either a paginated body {"results": [...]} or a bare JSON array. The client assumed a dict and used resp["results"], which raised TypeError: list indices must be integers or slices, not str on the href fallback path (after an empty build_id query) and could affect _find_artifact_content the same way.

Why
Upload/result gathering failed in production when the href query returned a list-shaped body, so content was never found even though the API had responded with data.

How
Added content_find_results_from_json() in pulp_tool/utils/response_utils.py to normalize both shapes to a list of dicts. gather_content_data() in pulp_client.py uses it for the build-id and href queries; _find_artifact_content() in upload_service.py uses it for href lookups. Tests cover the helper, href fallback with list JSON, and _find_artifact_content with list JSON.

How to test

git fetch origin
make lint
make format   # if needed
pre-commit run --all-files
make test
make test-diff-coverage

Notes for reviewers

  • Scope: 6 files (pulp_client.py, upload_service.py, response_utils.py, plus tests).
  • User-facing impact: avoids crashes and allows gather-by-href when the server returns an array.
  • Merge gate: 100% diff coverage vs base is satisfied locally via make test-diff-coverage.

Files touched (vs origin/main)
pulp_tool/api/pulp_client.py, pulp_tool/services/upload_service.py, pulp_tool/utils/response_utils.py, tests/api/test_pulp_client.py, tests/test_upload.py, tests/utils/test_response_utils.py, CHANGELOG.md.

@jajreidy jajreidy requested a review from a team as a code owner March 26, 2026 12:40
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Mar 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.01%. Comparing base (0e424ea) to head (288a8d1).
⚠️ Report is 106 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #90      +/-   ##
==========================================
+ Coverage   95.53%   97.01%   +1.47%     
==========================================
  Files          70       74       +4     
  Lines        3946     5352    +1406     
==========================================
+ Hits         3770     5192    +1422     
+ Misses        176      160      -16     
Flag Coverage Δ
unit-tests 97.01% <100.00%> (?)
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pulp_tool/api/pulp_client.py 96.58% <100.00%> (+3.23%) ⬆️
pulp_tool/services/upload_service.py 89.86% <100.00%> (+10.99%) ⬆️
pulp_tool/utils/response_utils.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jajreidy jajreidy merged commit 1037fd9 into konflux-ci:main Mar 26, 2026
5 checks passed
@jajreidy jajreidy deleted the fix-build-id-search branch March 26, 2026 13:05
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.

2 participants