mirror of https://github.com/pulumi/pulumi.git
3c1a6f4a12
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 |
||
---|---|---|
.. | ||
test_codegen.py |