Skip to content

OSIDB:5038 - Wrap bulk PUT external errors with affect context#1305

Open
svelamak wants to merge 3 commits into
masterfrom
fix/OSIDB-5038-wrap-bulk-put-errors
Open

OSIDB:5038 - Wrap bulk PUT external errors with affect context#1305
svelamak wants to merge 3 commits into
masterfrom
fix/OSIDB-5038-wrap-bulk-put-errors

Conversation

@svelamak

@svelamak svelamak commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Wraps external errors in the bulk affect PUT endpoint with meaningful context.

  • Updated bulk_put to collect per-item errors when affect failed in api_views.py
  • Updated existing test and added new test case
    Closes: OSIDB-5038

Summary by CodeRabbit

  • Bug Fixes

    • The bulk update endpoint now provides detailed error information for failed items instead of a single error response, returning both successful results and individual failure details with context.
  • Documentation

    • Updated changelog to document the bulk PUT endpoint improvements.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@svelamak, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 34 minutes and 4 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Enterprise

Run ID: 1061295c-b268-4b49-8e47-26ad57458afa

📥 Commits

Reviewing files that changed from the base of the PR and between 88b78c4 and b7d423f.

📒 Files selected for processing (2)
  • .secrets.baseline
  • osidb/api_views.py
📝 Walkthrough

Walkthrough

AffectView.bulk_put now catches per-item ValidationErrors during save, wraps them with affect context fields (uuid, ps_update_stream, ps_component, purl, ps_module), and returns HTTP 200 with {"results": ..., "failed": ...} instead of failing the whole request. Tests and changelog are updated accordingly.

Changes

Bulk PUT per-item ValidationError reporting

Layer / File(s) Summary
bulk_put error accumulation and response shape
osidb/api_views.py
bulk_put wraps each serializer .save() in a try/except block, collects ValidationError details alongside the originating input context, and changes the final response from {"results": ret} to {"results": ..., "failed": ...}, returning HTTP 200 in all cases.
Tests and changelog
osidb/tests/endpoints/test_affects.py, docs/CHANGELOG.md
Existing bulk PUT test updated to expect HTTP 200 with response.data["failed"] instead of HTTP 400. New test test_bulk_put_external_error_includes_context mocks AffectSerializer.save to raise ValidationError and asserts the failed entry's input contains the expected affect context fields. Changelog entry added under Unreleased/Fixed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • RedHatProductSecurity/osidb#1254: Introduces the failed field and partial-success handling for the bulk affects endpoint, which this PR extends by adding per-item affect context to the wrapped errors.

Poem

🐇 Hop hop, no more total doom,
When one affect fails, the rest have room!
Each error wrapped with context neat,
ps_component, purl — so complete.
HTTP 200 hops along,
A partial win still counts as strong! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: wrapping external errors with affect context in the bulk PUT endpoint, which is the core objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/OSIDB-5038-wrap-bulk-put-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@osidb/api_views.py`:
- Around line 1431-1435: In the bulk PUT failure error handling block where
error_detail is assigned, fix the typo in the fallback error key by changing
"non_filed_errors" to "non_field_errors" to match DRF conventions and maintain
consistency with the bulk POST path. This single-character fix (changing "filed"
to "field") ensures error payloads are consistent and client-side error parsing
works correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Enterprise

Run ID: 6dde8e7b-fe57-4d71-8b79-64dc27e47c72

📥 Commits

Reviewing files that changed from the base of the PR and between a895f82 and 88b78c4.

📒 Files selected for processing (3)
  • docs/CHANGELOG.md
  • osidb/api_views.py
  • osidb/tests/endpoints/test_affects.py

Comment thread osidb/api_views.py
@svelamak svelamak requested a review from a team June 15, 2026 18: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.

1 participant