Skip to content

Add error_on_reject for partial package policy rejection - #1307

Open
gerrod3 wants to merge 1 commit into
pulp:mainfrom
gerrod3:cursor/error-on-reject
Open

Add error_on_reject for partial package policy rejection#1307
gerrod3 wants to merge 1 commit into
pulp:mainfrom
gerrod3:cursor/error-on-reject

Conversation

@gerrod3

@gerrod3 gerrod3 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Allow repositories to skip packages rejected by blocklist or substitution policies instead of failing the entire version.

closes #1278
Assisted By: Cursor Grok 4.5

📜 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

See: Pull Request Walkthrough

@gerrod3
gerrod3 force-pushed the cursor/error-on-reject branch 5 times, most recently from a5298c3 to 3d9e3a5 Compare August 4, 2026 20:17
@gerrod3
gerrod3 marked this pull request as ready for review August 4, 2026 20:18
Allow repositories to skip packages rejected by blocklist or
substitution policies instead of failing the entire version.

closes pulp#1278
Assisted By: Cursor Grok 4.5

Co-authored-by: Cursor <cursoragent@cursor.com>
@gerrod3
gerrod3 force-pushed the cursor/error-on-reject branch from 3d9e3a5 to 7adc01b Compare August 4, 2026 20:28
Comment thread pulp_python/app/models.py
Comment on lines 428 to +430
When allow_package_substitution is False, reject any new version that would implicitly
replace existing content with different checksums (content substitution).
replace existing content with different checksums (content substitution), unless
error_on_reject is False, in which case the conflicting packages are skipped.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This mentions error_on_reject only for package substitution, but it also applies to the blocklist check. Also "unless error_on_reject is False" is a bit hard to read as a double negative.

Comment thread pulp_python/app/models.py
for dup in duplicates:
for pk in dup.duplicate_pks:
if pk in added_pks:
to_remove_pks.append(pk)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if we have two new packages with the same filename? Will be both marked for removal?

Comment thread pulp_python/app/models.py
PythonPackageContent.objects.filter(pk__in=[p.pk for p in blocked])
)
self._report_rejected_packages(
[pkg.filename for pkg in blocked],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For package substitution we log filenames + pks, but for blocklist only filenames. Should we make it consistent?

Comment thread pulp_python/app/models.py
def find_blocklisted_packages(self, packages):
"""
Raise a ValidationError if any of the given packages match a blocklist entry.
Return the packages from ``packages`` that match a blocklist entry.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Double `` instead of `

Comment thread pulp_python/app/models.py
break
return blocked

def check_blocklist_for_packages(self, packages):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you move content of check_blocklist_for_packages into _early_blocklist_check in PythonRepositoryViewSet and drop check_blocklist_for_packages entirely? Having three blocklist methods in the model class seems to be a lot, _check_blocklist and find_blocklisted_packages should be enough.

Comment thread pulp_python/app/models.py
"""
Record skipped packages in a task progress report.
"""
suffix = "; ".join(details)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to store the same info in suffix as in logs?

### Disable failing on rejected packages

```bash
pulp python repository update --repository "foo" --no-error-on-reject

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

error-on-reject is not implemented in the CLI yet. You can use httpie for now and change it back later once the CLI support is added.

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.

Partial rejection for allow_package_substitution=False on batch modify()

2 participants