Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure devops webhook call fails on parsing time #183

Open
DarkosGahan opened this issue Dec 11, 2024 · 4 comments
Open

Azure devops webhook call fails on parsing time #183

DarkosGahan opened this issue Dec 11, 2024 · 4 comments
Assignees

Comments

@DarkosGahan
Copy link

DarkosGahan commented Dec 11, 2024

Hi,

A webhook call from azure devops fails with the following message:

webhook-go[XXXXX]: &time.ParseError{Layout:"2006-01-02T15:04:05Z07:00", Value:"0001-01-01T00:00:00", LayoutElem:"Z07:00", ValueElem:"", Message:""}

webhook-go[XXXXX]: time="2024-12-11T08:09:12Z" level=error msg="error parsing webhook: parsing time "0001-01-01T00:00:00" as "2006-01-02T15:04:05Z07:00": cannot parse "" as "Z07:00""
both azuredevops and server are set to UTC

I can see the following data in the event details on the azure devops webhook:


    "eventType": "git.push",
    "publisherId": "tfs",
    ....
    ... 
   "date": "2024-12-11T08:08:48Z"

image

I have no knowledge in go so I am unable to fix it by myself
Thank you

@DarkosGahan
Copy link
Author

DarkosGahan commented Dec 12, 2024

The AZ webhook payload contains the parent project field which is having the LastUpdateTime field filled invalid

repository": {
"id": "",
"name": "puppet",
"url": "https://",
"project": {
"id": "",
"name": "",
"url": "https://",
"state": "wellFormed",
"visibility": "unchanged",
"lastUpdateTime": "0001-01-01T00:00:00"
},
"defaultBranch": "refs/heads/main",
"remoteUrl": ""
},
"pushedBy": {
"displayName": "",
"url": "",
"_links": {
"avatar": {
"href": ""
}
},
"id": "",
"uniqueName": "",
"imageUrl": "",
"descriptor": ""
},

@dhollinger
Copy link
Member

dhollinger commented Dec 23, 2024

@DarkosGahan Do you have a sanitized JSON sample I can use for testing?

That field is not shown for a code push in the sample docs: https://learn.microsoft.com/en-us/azure/devops/service-hooks/events?toc=%2Fazure%2Fdevops%2Fmarketplace-extensibility%2Ftoc.json&view=azure-devops#code-pushed

It's also important to note that we parse the JSON directly into the GitPush Struct that the AzureDevOps library provides, so we're just parsing the Payload into that struct, so if it's failing, you're somehow getting bad data into the payload... or using an unsupported event..... Webhook-Go only supports Push events at this time.

@dhollinger dhollinger self-assigned this Dec 23, 2024
@DarkosGahan
Copy link
Author

DarkosGahan commented Jan 7, 2025

Hello David,

Hopefully, this helps, this is the event returned by azure. I have attached a txt file, the json struct doesn't seem to get indented when pasting the text as code.
json_event.txt

the webhook seem to fail on the date provided for the main project, which indeed doesn't make sense. I have checked with our teams and nobody seem to know how to modify that date.

@dhollinger dhollinger added bug Something isn't working and removed bug Something isn't working labels Jan 8, 2025
@dhollinger
Copy link
Member

@DarkosGahan I dug into the payload you gave me some more and found that the .resource.repository.project.lastUpdateTime format is completely inconsistent with the remainder of the date fields in the payload. That particular field has "0001-01-01T00:00:00" as the output, however, it is supposed to be outputting in the "0001-01-01T00:00:00Z" format.

  • Incorrect format (for parser): "0001-01-01T00:00:00"
  • Expected format: "0001-01-01T00:00:00Z"

The error you are seeing comes from the parser expecting expecting that latter format. I tested using the PushEvent type from the official Azure DevOps git package for Go from Microsoft and ran into the same issue. It expects the format to be in 0001-01-01T00:00:00Z00 format. If you are receiving this from Azure DevOps, check any settings to ensure nothing is getting overwritten or contact Microsoft Support.

Updating the code to parse each date/time field in the payload differently is not something that is viable to do on our end. That would require too much logic and the JSON payload should never be mixing and matching date/time formats within the same payload for this specific reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants