When running the advisor upgrade-plan apply --push command in an automated CI/CD pipeline to generate step-by-step pull requests, the pipeline consistently fails with the following error in the logs:
Could not create Pull Request for [Repository name: <repo> - Current Branch: main - New Branch: main-upgrade-plan]:
{"message":"Invalid tree info","documentation_url":"https://docs.github.com/rest/git/trees#create-a-tree","status":"422"}
Spring App Advisor 1.6.x
This is suspected to be caused by a limitation in how the underlying Java GitHub API client (kohsuke/github-api) constructs the Git tree payload for certain changes (e.g. file deletions), which can result in an invalid tree reference being sent to GitHub's Create Tree API.
This issue will be fixed in Spring Application Advisor 2.0.
While the fixed version is released or if you can't immediately upgrade, the workaround consist on decoupling the local code changes from the Git/PR operations: let Application Advisor only modify files on disk, and handle branch creation, commit, push, and pull request creation yourself using native git and the GitHub CLI (gh). This avoids the GitHub API's tree-creation endpoint entirely for the commit step, so it isn't affected by this issue.
You must write a script (or workflow step) that does the following:
git add the working tree, then git commit). git push.gh pr create, targeting your base branch. Authenticate gh with the same token you were already using for Advisor's --push flow.