Skip to content

Error message: secret referenced in incoming-webhook repo-incoming-secret is empty or key is not existent #2346

@sjoerde-of

Description

@sjoerde-of

Hello,
We're upgrading from PAC v0.33.2 to v0.37.3. On the old version we successfully worked with incoming webhooks according to this page: https://pipelinesascode.com/docs/guide/incoming_webhook/

On the new version we got the following error:
"msg":"error processing incoming webhook: secret referenced in incoming-webhook repo-incoming-secret is empty or key is not existent"

It took us a bit of time to figure out that even though we used the default value for the key of our Secret, equivalent to the value of defaultIncomingWebhookSecretKey, that the controller is not falling back to this defaultIncomingWebhookSecretKey.
Please note the two spaces between "key" and "is not existent", as if the key is empty or nil.

In your code you do an empty check, but not a nil check. Could this be our problem?

secretOpts := ktypes.GetSecretOpt{
Namespace: repo.Namespace,
Name: hook.Secret.Name,
Key: hook.Secret.Key,
}
if secretOpts.Key == "" {
secretOpts.Key = defaultIncomingWebhookSecretKey
}
secretValue, err := l.kint.GetSecret(ctx, secretOpts)
if err != nil {
return false, nil, fmt.Errorf("error getting secret referenced in incoming-webhook: %w", err)
}
if secretValue == "" {
return false, nil, fmt.Errorf("secret referenced in incoming-webhook %s is empty or key %s is not existent", hook.Secret.Name, hook.Secret.Key)
}

We now have a workaround that solves our problem by explicitly defining the secret key:

spec:
  incoming:
    - secret:
        name: repo-incoming-secret
        key: secret

but I thought to share our issue here with you as well. I hope this is useful for you.
Kind regards,
Sjoerd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions