Add error_on_reject for partial package policy rejection - #1307
Conversation
a5298c3 to
3d9e3a5
Compare
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>
3d9e3a5 to
7adc01b
Compare
| 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. |
There was a problem hiding this comment.
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.
| for dup in duplicates: | ||
| for pk in dup.duplicate_pks: | ||
| if pk in added_pks: | ||
| to_remove_pks.append(pk) |
There was a problem hiding this comment.
What if we have two new packages with the same filename? Will be both marked for removal?
| PythonPackageContent.objects.filter(pk__in=[p.pk for p in blocked]) | ||
| ) | ||
| self._report_rejected_packages( | ||
| [pkg.filename for pkg in blocked], |
There was a problem hiding this comment.
For package substitution we log filenames + pks, but for blocklist only filenames. Should we make it consistent?
| 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. |
| break | ||
| return blocked | ||
|
|
||
| def check_blocklist_for_packages(self, packages): |
There was a problem hiding this comment.
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.
| """ | ||
| Record skipped packages in a task progress report. | ||
| """ | ||
| suffix = "; ".join(details) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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
See: Pull Request Walkthrough