diff --git a/internal/tofu/node_provider.go b/internal/tofu/node_provider.go index d45d37c672..53156de4c9 100644 --- a/internal/tofu/node_provider.go +++ b/internal/tofu/node_provider.go @@ -106,7 +106,7 @@ func (n *NodeApplyableProvider) ValidateProvider(ctx EvalContext, providerKey ad } schemaResp := provider.GetProviderSchema() - diags := schemaResp.Diagnostics.InConfigBody(configBody, n.Addr.String()) + diags := schemaResp.Diagnostics.InConfigBody(configBody, n.Addr.InstanceString(providerKey)) if diags.HasErrors() { return diags } @@ -139,7 +139,7 @@ func (n *NodeApplyableProvider) ValidateProvider(ctx EvalContext, providerKey ad } validateResp := provider.ValidateProviderConfig(req) - diags = diags.Append(validateResp.Diagnostics.InConfigBody(configBody, n.Addr.String())) + diags = diags.Append(validateResp.Diagnostics.InConfigBody(configBody, n.Addr.InstanceString(providerKey))) return diags } @@ -153,7 +153,7 @@ func (n *NodeApplyableProvider) ConfigureProvider(ctx EvalContext, providerKey a configBody := buildProviderConfig(ctx, n.Addr, config) resp := provider.GetProviderSchema() - diags := resp.Diagnostics.InConfigBody(configBody, n.Addr.String()) + diags := resp.Diagnostics.InConfigBody(configBody, n.Addr.InstanceString(providerKey)) if diags.HasErrors() { return diags } @@ -193,7 +193,7 @@ func (n *NodeApplyableProvider) ConfigureProvider(ctx EvalContext, providerKey a // ValidateProviderConfig is only used for validation. We are intentionally // ignoring the PreparedConfig field to maintain existing behavior. validateResp := provider.ValidateProviderConfig(req) - diags = diags.Append(validateResp.Diagnostics.InConfigBody(configBody, n.Addr.String())) + diags = diags.Append(validateResp.Diagnostics.InConfigBody(configBody, n.Addr.InstanceString(providerKey))) if diags.HasErrors() && config == nil { // If there isn't an explicit "provider" block in the configuration, // this error message won't be very clear. Add some detail to the error @@ -217,7 +217,7 @@ func (n *NodeApplyableProvider) ConfigureProvider(ctx EvalContext, providerKey a } configDiags := ctx.ConfigureProvider(n.Addr, providerKey, unmarkedConfigVal) - diags = diags.Append(configDiags.InConfigBody(configBody, n.Addr.String())) + diags = diags.Append(configDiags.InConfigBody(configBody, n.Addr.InstanceString(providerKey))) if diags.HasErrors() && config == nil { // If there isn't an explicit "provider" block in the configuration, // this error message won't be very clear. Add some detail to the error diff --git a/internal/tofu/node_resource_abstract_instance.go b/internal/tofu/node_resource_abstract_instance.go index 714a0356b8..0dc4022f6f 100644 --- a/internal/tofu/node_resource_abstract_instance.go +++ b/internal/tofu/node_resource_abstract_instance.go @@ -947,7 +947,7 @@ func (n *NodeAbstractResourceInstance) plan( var buf strings.Builder fmt.Fprintf(&buf, "[WARN] Provider %q produced an invalid plan for %s, but we are tolerating it because it is using the legacy plugin SDK.\n The following problems may be the cause of any confusing errors from downstream operations:", - n.ResolvedProvider.ProviderConfig, n.Addr, + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr, ) for _, err := range errs { fmt.Fprintf(&buf, "\n - %s", tfdiags.FormatError(err)) @@ -960,7 +960,7 @@ func (n *NodeAbstractResourceInstance) plan( "Provider produced invalid plan", fmt.Sprintf( "Provider %q planned an invalid value for %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig, tfdiags.FormatErrorPrefixed(err, n.Addr.String()), + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), tfdiags.FormatErrorPrefixed(err, n.Addr.String()), ), )) } @@ -1024,7 +1024,7 @@ func (n *NodeAbstractResourceInstance) plan( "Provider produced invalid plan", fmt.Sprintf( "Provider %q has indicated \"requires replacement\" on %s for a non-existent attribute path %#v.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig, n.Addr, path, + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr, path, ), )) continue @@ -1164,7 +1164,7 @@ func (n *NodeAbstractResourceInstance) plan( "Provider produced invalid plan", fmt.Sprintf( "Provider %q planned an invalid value for %s%s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig, n.Addr, tfdiags.FormatError(err), + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr, tfdiags.FormatError(err), ), )) } @@ -1582,7 +1582,7 @@ func (n *NodeAbstractResourceInstance) readDataSource(ctx EvalContext, configVal "Provider produced invalid object", fmt.Sprintf( "Provider %q produced an invalid value for %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig, tfdiags.FormatErrorPrefixed(err, n.Addr.String()), + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), tfdiags.FormatErrorPrefixed(err, n.Addr.String()), ), )) } @@ -1596,7 +1596,7 @@ func (n *NodeAbstractResourceInstance) readDataSource(ctx EvalContext, configVal "Provider produced null object", fmt.Sprintf( "Provider %q produced a null value for %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig, n.Addr, + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr, ), )) } @@ -1607,7 +1607,7 @@ func (n *NodeAbstractResourceInstance) readDataSource(ctx EvalContext, configVal "Provider produced invalid object", fmt.Sprintf( "Provider %q produced a value for %s that is not wholly known.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig, n.Addr, + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr, ), )) @@ -1682,7 +1682,7 @@ func (n *NodeAbstractResourceInstance) planDataSource(ctx EvalContext, checkRule schema, _ := providerSchema.SchemaForResourceAddr(n.Addr.ContainingResource().Resource) if schema == nil { // Should be caught during validation, so we don't bother with a pretty error here - diags = diags.Append(fmt.Errorf("provider %q does not support data source %q", n.ResolvedProvider.ProviderConfig, n.Addr.ContainingResource().Resource.Type)) + diags = diags.Append(fmt.Errorf("provider %q does not support data source %q", n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr.ContainingResource().Resource.Type)) return nil, nil, keyData, diags } @@ -1965,7 +1965,7 @@ func (n *NodeAbstractResourceInstance) applyDataSource(ctx EvalContext, planned schema, _ := providerSchema.SchemaForResourceAddr(n.Addr.ContainingResource().Resource) if schema == nil { // Should be caught during validation, so we don't bother with a pretty error here - diags = diags.Append(fmt.Errorf("provider %q does not support data source %q", n.ResolvedProvider.ProviderConfig, n.Addr.ContainingResource().Resource.Type)) + diags = diags.Append(fmt.Errorf("provider %q does not support data source %q", n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr.ContainingResource().Resource.Type)) return nil, keyData, diags } @@ -2453,7 +2453,7 @@ func (n *NodeAbstractResourceInstance) apply( "Provider produced invalid object", fmt.Sprintf( "Provider %q produced an invalid nil value after apply for %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig.String(), n.Addr.String(), + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr.String(), ), )) } @@ -2466,7 +2466,7 @@ func (n *NodeAbstractResourceInstance) apply( "Provider produced invalid object", fmt.Sprintf( "Provider %q produced an invalid value after apply for %s. The result cannot not be saved in the OpenTofu state.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.ResolvedProvider.ProviderConfig.String(), tfdiags.FormatErrorPrefixed(err, n.Addr.String()), + n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), tfdiags.FormatErrorPrefixed(err, n.Addr.String()), ), )) } @@ -2536,7 +2536,7 @@ func (n *NodeAbstractResourceInstance) apply( // to notice in the logs if an inconsistency beyond the type system // leads to a downstream provider failure. var buf strings.Builder - fmt.Fprintf(&buf, "[WARN] Provider %q produced an unexpected new value for %s, but we are tolerating it because it is using the legacy plugin SDK.\n The following problems may be the cause of any confusing errors from downstream operations:", n.ResolvedProvider.ProviderConfig.String(), n.Addr) + fmt.Fprintf(&buf, "[WARN] Provider %q produced an unexpected new value for %s, but we are tolerating it because it is using the legacy plugin SDK.\n The following problems may be the cause of any confusing errors from downstream operations:", n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), n.Addr) for _, err := range errs { fmt.Fprintf(&buf, "\n - %s", tfdiags.FormatError(err)) } @@ -2556,7 +2556,7 @@ func (n *NodeAbstractResourceInstance) apply( "Provider produced inconsistent result after apply", fmt.Sprintf( "When applying changes to %s, provider %q produced an unexpected new value: %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.", - n.Addr, n.ResolvedProvider.ProviderConfig.String(), tfdiags.FormatError(err), + n.Addr, n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey), tfdiags.FormatError(err), ), )) } diff --git a/internal/tofu/node_resource_import.go b/internal/tofu/node_resource_import.go index 941560ce17..ed0b71daae 100644 --- a/internal/tofu/node_resource_import.go +++ b/internal/tofu/node_resource_import.go @@ -97,7 +97,7 @@ func (n *graphNodeImportState) Execute(ctx EvalContext, op walkOperation) (diags return diags } n.ResolvedProviderKey = asAbsNode.ResolvedProviderKey - log.Printf("[TRACE] graphNodeImportState: importing using %s instance %s", n.ResolvedProvider.ProviderConfig, n.ResolvedProviderKey) + log.Printf("[TRACE] graphNodeImportState: importing using %s", n.ResolvedProvider.ProviderConfig.InstanceString(n.ResolvedProviderKey)) provider, _, err := getProvider(ctx, n.ResolvedProvider.ProviderConfig, n.ResolvedProviderKey) diags = diags.Append(err)