-
Notifications
You must be signed in to change notification settings - Fork 84
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
Use InputPropertyError for validations in the node group components #1592
Conversation
This change is part of the following stack: Change managed by git-spice. |
Does the PR have any schema changes?Looking good! No breaking changes found. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add screenshots of before and after error messages to the PR? I'm especially interested in what it looks like for errors that are due to the interaction between multiple properties.
`an instanceProfile or instanceProfileName is required`, | ||
parent, | ||
); | ||
throw new pulumi.InputPropertyError({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these cases where the error could be attributed to multiple properties should we add two property errors or should it stay as a resource error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like a single input property error is enough here.
The benefit of the input property error is that a user will be presented with all errors and not only the first validation that failed.
For example compare those two errors for the same program:
IMO we shouldn't create multiple errors for the same issue when there's multiple properties involved. That's just gonna increase the cognitive complexity of understanding the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see. I wasn't sure how the property errors would be shown, but since they are just listed out under the resource then that makes total sense.
It looks like that value {{urn:pulumi:..}
is something that the engine adds? I'm assuming it only works with primitive types or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how dependency resources are visualized here. I guess the URN is the only sensible value that can be shown here 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, does it resolve Output
values correctly? Wondering if we ever need to be careful about what kind of values we can include here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the message the engine adds, right? No, this one shows either that it's an output (e.g. during preview) or the resolved value if it's already resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a couple of questions for my own interest.
Do you know if there is a guide anywhere on these new error types? Looking at the linked docs it doesn't look like there is any info on how to use (i.e. my questions on this PR)
); | ||
const validationErrors: pulumi.InputPropertyErrorDetails[] = []; | ||
|
||
const instanceProfileName = core.apply((c) => resolveInstanceProfileName(args, c)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when you throw inside of an apply? Do we still get the rest of the validation errors unless they depend on instanceProfileName
? And if we eventually do throw because of other errors do these get surfaced then?
`invalid args for node group ${name}, nodeSecurityGroup and nodeSecurityGroupId are mutually exclusive`, | ||
parent, | ||
); | ||
validationErrors.push({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we no longer throw here and keep going, can that lead to us being in a bad place? When we use validation errors like this, do we need to make sure we throw validation errors before any resources are created?
In this case I think we do throw before creating resources, but I'm just curious for future reference.
`an instanceProfile or instanceProfileName is required`, | ||
parent, | ||
); | ||
throw new pulumi.InputPropertyError({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, does it resolve Output
values correctly? Wondering if we ever need to be careful about what kind of values we can include here.
8aea025
to
929ccdc
Compare
This PR has been shipped in release v3.8.0. |
pu/pu introduced new error types for component authors to use. The
InputPropertyError
andInputPropertiesError
errors are pretty printed by the engine and don't confuse users with a load of GRPC stack traces (see docs). Additionally those errors accumulate multiple validation errors and allow presenting them all to users. Previously we exited on the first error.For adding EFA support (#1564) we'd like to make use of these new errors. In preparation for that I've updated the node group components to make use of this new error type.
UX:
Old (missing the second error):
![Screenshot 2025-01-23 at 11 01 38](https://private-user-images.githubusercontent.com/2453580/405979200-260a3467-100d-4ba7-9871-6d852ac8e2a7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ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