Skip to content

Commit 70b6a7c

Browse files
AlinsRanCopilot
andcommitted
fix: skip duplicate key-auth check for malformed credential JSON
Returning the unmarshal error would deny Consumers with malformed inline credential config, and also deny new Consumers when any existing Consumer has a malformed credential (because we'd fail while reading the existing consumer's keys). Log at debug level and skip the credential from duplicate detection instead, preserving the original fail-open behaviour. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 58ce2fb commit 70b6a7c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/webhook/v1/consumer_webhook.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,11 @@ func (v *ConsumerCustomValidator) extractCredentialKey(ctx context.Context, cons
231231
Key string `json:"key"`
232232
}
233233
if err := json.Unmarshal(credential.Config.Raw, &cfg); err != nil {
234-
return "", err
234+
// Malformed JSON is not a hard error: skip duplicate detection for this
235+
// credential so existing consumers with bad config are not suddenly denied.
236+
consumerLog.V(1).Info("skipping duplicate key-auth check: malformed credential config",
237+
"consumer", consumer.Name, "error", err)
238+
return "", nil
235239
}
236240
return cfg.Key, nil
237241
}

0 commit comments

Comments
 (0)