pulumi/tests/testdata/codegen/regress-py-14012/python/codegen-manifest.json

13 lines
256 B
JSON
Raw Permalink Normal View History

[sdkgen/python] Fix error calling _configure when the value is None (#14014) We recently fixed an issue where defaults weren't set for nested objects when the nested objects are passed as dicts (#13825). Unfortunately, this introduced a regression when the nested object is optional, but it itself has required fields, and the nested object is not specified. In that case, an unintended error is raised. Consider a `Provider` resource with an optional `certmanager: ProviderCertmanagerArgs` argument, which itself has two required properties: `mtls_cert_pem` and `mtls_key_pem`. When creating a new `Provider` without specifying a `certmanager`, we get an error: ``` TypeError: ProviderCertmanagerArgs._configure() missing 2 required positional arguments: 'mtls_cert_pem' and 'mtls_key_pem' ``` The source of the problem is this check in the generated `Provider`'s constructor: ```python if not isinstance(certmanager, ProviderCertmanagerArgs): certmanager = certmanager or {} def _setter(key, value): certmanager[key] = value ProviderCertmanagerArgs._configure(_setter, **certmanager) ``` When `certmanager` is not specified, its value is `None`, which is also not an instance of `ProviderCertmanagerArgs`. So the code inside the `if` executes. `ProviderCertmanagerArgs._configure` is called on an empty dict, and the error is raised because there are two required positional arguments to `ProviderCertmanagerArgs._configure`. The fix is to add an additional check to ensure the value is not `None`. Fixes #14012
2023-09-22 18:28:25 +00:00
{
"emittedFiles": [
"pulumi_foo/README.md",
"pulumi_foo/__init__.py",
"pulumi_foo/_inputs.py",
"pulumi_foo/_utilities.py",
"pulumi_foo/provider.py",
"pulumi_foo/pulumi-plugin.json",
"pulumi_foo/py.typed",
"setup.py"
]
}