Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't raise CraftValidationErrors in validators #600

Merged
merged 3 commits into from
Jun 21, 2024

Conversation

tigarmo
Copy link
Collaborator

@tigarmo tigarmo commented Jun 21, 2024

The rule is this: in validators, always raise the types that Pydantic expects (ValueErrors, AssertionErrors, TypeError, and subclasses of these). This allows Pydantic to capture all errors and group them into a single ValidationError, which we can then convert into a single CraftValidationError in from_yaml_data(). This provides a more uniform UI for the reporting of validation errors on the project.

  • Have you signed the CLA?

tigarmo added 2 commits June 21, 2024 15:03
The rule is this: in validators, always raise the types that Pydantic
expects (ValueErrors, AssertionErrors, TypeError, and subclasses of these).
This allows Pydantic to capture all errors and group them into a single
ValidationError, which we can then convert into a single CraftValidationError
in from_yaml_data(). This provides a more uniform UI for the reporting of
validation errors on the project.
@tigarmo tigarmo force-pushed the work/fix-validation-errors branch from 0748d5f to 73806b6 Compare June 21, 2024 18:03
rockcraft/models/project.py Outdated Show resolved Hide resolved
rockcraft/models/project.py Show resolved Hide resolved
Copy link
Contributor

@dariuszd21 dariuszd21 left a comment

Choose a reason for hiding this comment

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

Looks good!

@tigarmo tigarmo added the squash label Jun 21, 2024
@tigarmo tigarmo merged commit 9412ed5 into main Jun 21, 2024
15 checks passed
@tigarmo tigarmo deleted the work/fix-validation-errors branch June 21, 2024 19:15
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.

3 participants