From f24015bf72c729e217aab5ac71d7142064642f57 Mon Sep 17 00:00:00 2001 From: Mikhail Shilkov Date: Wed, 8 Jan 2025 14:54:28 +0000 Subject: [PATCH] Add an assert on proposed name, amend the error message --- provider/pkg/metadata/naming.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/provider/pkg/metadata/naming.go b/provider/pkg/metadata/naming.go index 71b3416121..691d7f24c5 100644 --- a/provider/pkg/metadata/naming.go +++ b/provider/pkg/metadata/naming.go @@ -37,8 +37,9 @@ func AssignNameIfAutonamable(randomSeed []byte, engineAutonaming *pulumirpc.Chec if engineAutonaming != nil { switch engineAutonaming.Mode { case pulumirpc.CheckRequest_AutonamingOptions_DISABLE: - return errors.New("autonaming is disabled, please provide a name or generateName value") + return errors.New("autonaming is disabled, resource requires the .metadata.name field to be set") case pulumirpc.CheckRequest_AutonamingOptions_ENFORCE, pulumirpc.CheckRequest_AutonamingOptions_PROPOSE: + contract.Assertf(engineAutonaming.ProposedName != "", "expected proposed name to be non-empty: %v", engineAutonaming) autoname = engineAutonaming.ProposedName } }