Skip to content

Commit e665ff6

Browse files
committed
Prevent panics on invalid provider configuration
1 parent 32e9d39 commit e665ff6

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

pf/proto/schema.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package proto
1616

1717
import (
18-
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
18+
// "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
1919

2020
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
2121
)
@@ -36,8 +36,16 @@ func (pseudoResource) DecodeTimeouts(config shim.ResourceConfig) (*shim.Resource
3636
func getSchemaMap[T any](m interface {
3737
GetOk(string) (T, bool)
3838
}, key string) T {
39-
v, ok := m.GetOk(key)
40-
contract.Assertf(ok, "Could not find key %q", key)
39+
v, _ := m.GetOk(key)
40+
// Some functions (such as terraformToPulumiName; link: [1]) do not correctly use
41+
// GetOk, so we can't panic on Get for a missing value, even though that is the
42+
// point of Get.
43+
//
44+
// [^1]: https://github.com/pulumi/pulumi-terraform-bridge/blob/08338be75eedce29c4c2349109d72edc8a38930d/pkg/tfbridge/names.go#L154-L158
45+
//
46+
// contract.Assertf(ok, "Could not find key %q", key)
47+
//
48+
//nolint:lll
4149
return v
4250
}
4351

pf/tfbridge/provider_checkconfig.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ func (p *provider) validateProviderConfig(
197197
if k == "version" || k == "pluginDownloadURL" {
198198
continue
199199
}
200+
// TODO[https://github.com/pulumi/pulumi/issues/16757] While #16757 is
201+
// outstanding, we need to filter out the keys for parameterized providers
202+
// from the top level namespace.
203+
//
204+
// We will need to remove this check before we GA dynamic providers.
205+
if p.parameterize != nil {
206+
if k == "name" || k == "parameterization" {
207+
continue
208+
}
209+
}
200210
n := tfbridge.PulumiToTerraformName(string(k), p.schemaOnlyProvider.Schema(), p.info.GetConfig())
201211
_, known := p.configType.AttributeTypes[n]
202212
if !known {

0 commit comments

Comments
 (0)