Skip to content

Conversation

@gerrod3
Copy link
Contributor

@gerrod3 gerrod3 commented Jan 29, 2026

  • general_create/update now properly raise their ValidationErrors
  • there are new Sync/PublishErrors for plugins
  • import/export get their own errors
  • rest of the validation errors now inherit from PulpException

After looking through the plugins, most exceptions are some Runtime or ValueError and I'm not sure if there is an easy generic we can put into Pulpcore to cover all. Many of them are in our big tasks like sync/publish so I created two catch-alls for Sync & Publish. I was thinking of creating a specific error for Download failures, but our download logic is too convoluted to find a good place, and all the plugins do their own thing to check if a download failed. One big exception I didn't bother with is RBAC hooks. If they fail on object creation then the task won't show useful info, but this should only happen if the user customizes their access policies incorrectly.

fixes: #7270
Assisted-by: claude-4.5-sonnet
https://issues.redhat.com/browse/PULP-1171

📜 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 7270 branch 2 times, most recently from b484ef7 to b015f23 Compare January 30, 2026 04:10
Comment on lines 18 to 21
if error_code:
if not isinstance(error_code, str):
raise TypeError(_("Error code must be an instance of str."))
self.error_code = error_code
Copy link
Member

Choose a reason for hiding this comment

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

This is an abstract base class. So this seems overly complex.
We should be able to go with

def __init__(self):
    if not isinstance(self.error_code, str):
        raise NotImplementedError("ABC error. Subclass must define a unique error_code.")

Copy link
Member

Choose a reason for hiding this comment

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

One could think about making this capable of providing on-the-fly defined errors, but I think that would not be helping with the goal to get more consistent errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's partly why I made the class so complicated to keep the idea of defining on-the-fly errors, but it does go against trying to be more consistent.

Copy link
Member

@mdellweg mdellweg Jan 30, 2026

Choose a reason for hiding this comment

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

Maybe now that we are there:
return {"code": exc.error_code, "description": str(exc)}

This should help to make it machine readable.

@gerrod3 gerrod3 force-pushed the 7270 branch 2 times, most recently from 5892910 to 33b9695 Compare January 30, 2026 18:36
fixes: pulp#7270
Assisted-by: claude-4.5-sonnet
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.

Return useful information to user from base task-actions

3 participants