tinglesoftware/dependabot-azure-devops

How to debug POST /pushes 400 response

Closed this issue ยท 5 comments

I have a pipeline that has been working fine but now I see the following:

Updating Microsoft.AspNetCore.Authentication.JwtBearer from 6.0.16 to 6.0.18
Submitting Microsoft.AspNetCore.Authentication.JwtBearer pull request for creation.
๐ŸŒ --> GET https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/commits
๐ŸŒ <-- 200 https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/commits
๐ŸŒ --> GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.authentication.jwtbearer/6.0.18/microsoft.aspnetcore.authentication.jwtbearer.nuspec
๐ŸŒ <-- 200 https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.authentication.jwtbearer/6.0.18/microsoft.aspnetcore.authentication.jwtbearer.nuspec
๐ŸŒ --> GET https://github.com/dotnet/aspnetcore.git/info/refs?service=git-upload-pack
๐ŸŒ <-- 200 https://github.com/dotnet/aspnetcore.git/info/refs?service=git-upload-pack
๐ŸŒ --> GET https://github.com/dotnet/aspnetcore.git/info/refs?service=git-upload-pack
๐ŸŒ <-- 200 https://github.com/dotnet/aspnetcore.git/info/refs?service=git-upload-pack
๐ŸŒ --> GET https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/refs?filter=heads/dependabot/nuget/Microsoft.AspNetCore.Authentication.JwtBearer-6.0.18
๐ŸŒ <-- 200 https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/refs?filter=heads/dependabot/nuget/Microsoft.AspNetCore.Authentication.JwtBearer-6.0.18
๐ŸŒ --> POST https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/pushes?api-version=5.0
๐ŸŒ <-- 400 https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/pushes?api-version=5.0
๐ŸŒ --> GET https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend
๐ŸŒ <-- 200 https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend
๐ŸŒ --> POST https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/pullrequests?api-version=5.0
๐ŸŒ <-- 400 https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/pullrequests?api-version=5.0
bin/update-script.rb:857:in `block in <main>': Pull Request creation failed with status 400. Message: TF401398: The pull request cannot be activated because the source and/or the target branch no longer exists, or the requested refs are not branches (StandardError)
	from bin/update-script.rb:563:in `each'
	from bin/update-script.rb:563:in `<main>'
Failed! PR already exists or an error has occurred.

The last POST call that fails shows the message but the cause of that failure would be the first failing POST (to create the push). Is there any way to see the response of this POST call?

I am at a loss here, I did update all dependencies manually and then the build worked. A few days later it even created a PR. But now I have the same issue but with another package. I believe that there is some thing that goes wrong with the POST to create a push but I can not see what it is as the tool just skips over the 400.

I have other repositories in the same pipeline and they all work fine.

Do you have a repro for this?

Not that I can make available unfortunately. However the issue is not in dependabot-azure-devops per se, it is probably some setting or similar in our Azure DevOps that blocks it. It is just that I would like to see the response message of the 400 from :

--> POST https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/pushes?api-version=5.0
๐ŸŒ <-- 400 https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/pushes?api-version=5.0

similar to what happen to the second POST that returns 400:

๐ŸŒ <-- 400 https://dev.azure.com/<org>/<product>/_apis/git/repositories/backend/pullrequests?api-version=5.0
bin/update-script.rb:857:in `block in <main>': Pull Request creation failed with status 400. Message: TF401398: The pull request cannot be activated because the source and/or the target branch no longer exists, or the requested refs are not branches (StandardError)
	from bin/update-script.rb:563:in `each'
	from bin/update-script.rb:563:in `<main>'
Failed! PR already exists or an error has occurred.

and if that does not have a message (as have been the case before) then perhaps the body of the POST request so that I could recreate it.

As the error message points out, the source branch for the PR (should be something like dependabot/Microsoft.AspNetCore.Authentication.JwtBearer-6.0.18) does not exist. Both the source branch and the target branch (e.g. main, master, dev etc) must exist.

What you now need to debug is the creation of the branch.
To do this, you need to set the EXCON_DEBUG=1 environment variable.

For example:

- task: dependabot@1
  inputs:
    extraEnvironmentVariables: 'EXCON_DEBUG=1'

Thank you that allowed me to see the error. In case anyone has smilar issues my problem was that some csproj files had project dependency references with lower case path and the actual path had capital initial letter. This led to dependabot listing the files multiple times and the commit creation to fail as the csproj file referenced did not exist (case sensitive)