Skip to content

2.9.0-RC1: Azure Devops git webhooks do not match with http[s] schemas #15700

Closed
@AlexGS74

Description

@AlexGS74

Checklist:

  • [+ ] I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • [ +] I've included steps to reproduce the bug.
  • [ +] I've pasted the output of argocd version.

Describe the bug

I'm trying to setup Argocd webhook integration with Service Hooks in Azure DevOps.
I can see that the notifications from Azure do come through to Argo and I see these messages logged by ArgoCD-Server:

{"level":"debug","msg":"https://tenant-name@dev.azure.com/tenant-name/Project/_git/GitOps does not match (?i)^(http://|https://|[a-zA-Z0-9_\\.][a-zA-Z0-9_\\.-]{0,30}[a-zA-Z0-9_\\.\\$-]?@|ssh://([a-zA-Z0-9_\\.][a-zA-Z0-9_\\.-]{0,30}[a-zA-Z0-9_\\.\\$-]?@)?)dev\\.azure\\.com(:[0-9]+|)[:/]tenant-name/Project/_git/GitOps(\\.git)?$","time":"2023-09-27T18:57:10Z"}

You can see that the notificaiton and the app configuration look the same but the regexp still doesn't match thus making the webhook to ignore the Service Hook notification.

I believe the root cause is the issue with the regexp in this section below:

(?i)^(http://|https://**|**[a-zA-Z0-9_\\.][a-zA-Z0-9_\\.-]....

The "boldened" out with **|** makes it to OR on the http, https and the stuff that follows. So it doesn't accept https://user-name@.... The part for ssh doesn't have that issue and correctly matches the repos setup with ssh.

I believe this would be correct code to fix the regexp:

the excerpt is based on this PR

regexpStr := fmt.Sprintf(`(?i)^((http://|https://)%s@|ssh://(%s@)?)%s(:[0-9]+|)[:/]%s(\.git)?$`,
		usernameRegex, usernameRegex, regexEscapedHostname, regexEscapedPath)

To Reproduce

Follow the documentation to setup the Azure Service Hook. Turn on debug level logging in argocd-server.

Expected behavior

The notification should match.

Version

❯ argocd version
argocd: v2.3.3+07ac038.dirty
  BuildDate: 2022-03-30T05:20:18Z
  GitCommit: 07ac038a8f97a93b401e824550f0505400a8c84e
  GitTreeState: dirty
  GoVersion: go1.18
  Compiler: gc
  Platform: darwin/amd64
argocd-server: v2.9.0-rc1+b3fabc2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions