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

[sdk/python] Don't error on type mismatches when using input values for outputs #11422

Merged
merged 1 commit into from Nov 21, 2022

Conversation

justinvp
Copy link
Member

When resolving a resource's outputs, if an output value is missing (and it's not a preview), the SDK will see if there was an input prop of the same name as the output prop and use that input value as the value for the output. We do this across our SDKs. It can be problematic when the input prop's type isn't the same as the output prop's type. In the Python SDK, if the input value is a dict and the type of the output cannot be converted from a dict, then the SDK currently raises an AssertionError, which causes pulumi up to fail. This is inconsistent with the other language SDKs, which don't error during pulumi up in such cases.

This change changes the behavior of the Python SDK to not error when attempting to use an input value for the output value when there is a type mismatch. Instead of raising an error, None is returned, which is the same value that would be used if there had been no input value available to fill-in.

Note that this behavior of filling in input values for missing output values has mostly worked OK for custom resources where there's generally a 1:1 match between inputs/outputs, but obviously it does not work well when that's not the case (which is likely to be more common now with components). We likely need to re-think this overall for all SDKs, as a separate, future change (i.e. having some way to opt-in to disabling this behavior).

Fixes #11416

…or outputs

When resolving a resource's outputs, if an output value is missing (and it's not a preview), the SDK will see if there was an input prop of the same name as the output prop and use that input value as the value for the output. This can be problematic when the input prop's type isn't the same as the output prop's type. If the input value is a `dict` and the type of the output cannot be converted from a `dict`, then the SDK currently raises an `AssertionError`, which causes `pulumi up` to fail. This is inconsistent with the other language SDKs, which don't error during `pulumi up` in such cases.

This change changes the behavior of the Python SDK to not error when attempting to use an input value for the output value when there is a type mismatch. Instead of raising an error, `None` is returned, which is the same value that would be used if there had been no input value available to fill-in.
@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2022-11-21)

Bug Fixes

  • [sdk/python] Don't error on type mismatches when using input values for outputs
    #11422

@justinvp
Copy link
Member Author

bors merge

bors bot added a commit that referenced this pull request Nov 21, 2022
11422: [sdk/python] Don't error on type mismatches when using input values for outputs r=justinvp a=justinvp

When resolving a resource's outputs, if an output value is missing (and it's not a preview), the SDK will see if there was an input prop of the same name as the output prop and use that input value as the value for the output. We do this across our SDKs. It can be problematic when the input prop's type isn't the same as the output prop's type. In the Python SDK, if the input value is a `dict` and the type of the output cannot be converted from a `dict`, then the SDK currently raises an `AssertionError`, which causes `pulumi up` to fail. This is inconsistent with the other language SDKs, which don't error during `pulumi up` in such cases.

This change changes the behavior of the Python SDK to not error when attempting to use an input value for the output value when there is a type mismatch. Instead of raising an error, `None` is returned, which is the same value that would be used if there had been no input value available to fill-in.

Note that this behavior of filling in input values for missing output values has mostly worked OK for custom resources where there's generally a 1:1 match between inputs/outputs, but obviously it does not work well when that's not the case (which is likely to be more common now with components). We likely need to re-think this overall for all SDKs, as a separate, future change (i.e. having some way to opt-in to disabling this behavior).

Fixes #11416

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
@bors
Copy link
Contributor

bors bot commented Nov 21, 2022

Build failed:

@justinvp
Copy link
Member Author

bors retry

@bors
Copy link
Contributor

bors bot commented Nov 21, 2022

Build succeeded:

@bors bors bot merged commit 45dddd8 into master Nov 21, 2022
@bors bors bot deleted the justin/python_output_noerror branch November 21, 2022 23:14
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.

Error deserializing optional output resource
3 participants