Skip to content

Fix IntegrityError when first-time pull-through fails digest validation - #8233

Open
gerrod3 wants to merge 1 commit into
pulp:mainfrom
gerrod3:fix-pull-through-digest-failure
Open

gerrod3 wants to merge 1 commit into
pulp:mainfrom
gerrod3:fix-pull-through-digest-failure

Conversation

@gerrod3

@gerrod3 gerrod3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

On a first-time pull-through download, _match_and_stream builds the ContentArtifact and RemoteArtifact unsaved. If the download then fails digest validation, _stream_remote_artifact tries to save failed_at on the RA, which violates the core_remoteartifact foreign key to the never-saved CA.

Effects before this change:

  • The content app logs an FK IntegrityError instead of the intended "failed checksum validation" error.
  • close_tcp_connection is skipped, so the client gets a clean 200 OK with the full unvalidated body (checked with curl, exit 0).

Now failed_at is only recorded when the RA's ContentArtifact already exists. The connection is always closed and the RuntimeError always raised, so the client sees a broken transfer (curl: (18) transfer closed with outstanding read data remaining).

This does not add a failure cooldown for first-time pull-through; that is left for a follow-up.

Tests: two unit tests in pulpcore/tests/unit/content/test_handler.py. The new-ContentArtifact test fails without the fix with the FK IntegrityError. A functional test isn't possible since pull-through RAs carry no digests and pulp_file doesn't implement pull-through.

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

🤖 Generated with Claude Code

@gerrod3
gerrod3 force-pushed the fix-pull-through-digest-failure branch from abb6c7a to 654ee33 Compare October 16, 2026 17:05
…alidation

On a first-time pull-through the ContentArtifact is unsaved, so saving the
RemoteArtifact's failed_at violated the foreign key and raised an
IntegrityError. That skipped closing the connection and the intended
"failed checksum validation" error, letting clients receive the unvalidated
body as a clean 200. Only record failed_at when the ContentArtifact exists.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gerrod3
gerrod3 force-pushed the fix-pull-through-digest-failure branch from 654ee33 to cd76e46 Compare October 16, 2026 17:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant