-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[cli] Protect against panic when using incorrect token type in pulumi import #7202
Conversation
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 we add a test for this?
This feels like an okay fix for now to address the common user-facing issue - but I will say I think we will need to directionally do one of two things:
- Ensure that we validate all strings that we convert to type tokens at the point we take them from the outside world, and produce useful error messages there - and then assume that all things typed as
token.Type
are valid - Admit that we aren't cleanly ensuring that all things typed as
token.Type
are valid, and change the API fortoken.Type
to return errors instead of asserting (which would require a lot of changes to consumers to handle all the new error cases.
I personally think we should be doing (1). The changes in this PR aren't really either (1) or (2) - they are patching the problem in between these two in one place (but I'll bet there are dozens more like this as latent issues).
I definitely think we need to more in advance here - we can do something at the cli layer but we'd need to make sure that work is correct. Would you be ok for me to add a follow up issue here to make sure we investigate that but proceed with this to step any panics for now? |
Yep - happy to open a follow-up issue. Basically any place we use
The case that causes this particular bug is in the middle of the results above. Most of the others look like they are probably safe - but should likely still be using a parsing function and propagating an error just to be sure. |
Fixes: #6990
Previously:
After: