diff --git a/internal/cmd/api-key/command_store.go b/internal/cmd/api-key/command_store.go index d28d3ac53f..d8d3163413 100644 --- a/internal/cmd/api-key/command_store.go +++ b/internal/cmd/api-key/command_store.go @@ -82,7 +82,8 @@ func (c *command) store(cmd *cobra.Command, args []string) error { } else { cluster, err = c.Context.GetKafkaClusterForCommand() if err != nil { - return err + // Replace the error msg since it suggests flags which are unavailable with this command + return errors.NewErrorWithSuggestions(errors.NoKafkaSelectedErrorMsg, errors.APIKeyNotValidForClusterSuggestions) } } diff --git a/internal/pkg/errors/error_message.go b/internal/pkg/errors/error_message.go index e9681f81a4..78f873021e 100644 --- a/internal/pkg/errors/error_message.go +++ b/internal/pkg/errors/error_message.go @@ -401,7 +401,7 @@ const ( KafkaNotReadyErrorMsg = `Kafka cluster "%s" not ready` KafkaNotReadySuggestions = "It may take up to 5 minutes for a recently created Kafka cluster to be ready." NoKafkaSelectedErrorMsg = "no Kafka cluster selected" - NoKafkaSelectedSuggestions = "You must pass `--cluster` or `--resource` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`." + NoKafkaSelectedSuggestions = "You must pass `--cluster` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`." NoKafkaForDescribeSuggestions = "You must provide the cluster ID argument or set an active Kafka cluster in your context with `ccloud kafka cluster use`." NoAPISecretStoredErrorMsg = `no API secret for API key "%s" of resource "%s" stored in local CLI state` NoAPISecretStoredSuggestions = "Store the API secret with `confluent api-key store %s --resource %s`." diff --git a/test/fixtures/output/kafka/client-config/no-cluster.golden b/test/fixtures/output/kafka/client-config/no-cluster.golden index 1730daaf75..916bd7ca74 100644 --- a/test/fixtures/output/kafka/client-config/no-cluster.golden +++ b/test/fixtures/output/kafka/client-config/no-cluster.golden @@ -1,4 +1,4 @@ Error: no Kafka cluster selected Suggestions: - You must pass `--cluster` or `--resource` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`. + You must pass `--cluster` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`. diff --git a/test/fixtures/output/login/err-no-kafka.golden b/test/fixtures/output/login/err-no-kafka.golden index 1730daaf75..916bd7ca74 100644 --- a/test/fixtures/output/login/err-no-kafka.golden +++ b/test/fixtures/output/login/err-no-kafka.golden @@ -1,4 +1,4 @@ Error: no Kafka cluster selected Suggestions: - You must pass `--cluster` or `--resource` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`. + You must pass `--cluster` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`.