dailymotion-oss / octopilot

Automate your Gitops workflow, by automatically creating/merging GitHub Pull Requests

Home Page:https://dailymotion-oss.github.io/octopilot/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

422 Validation Failed [{Resource:PullRequest Field:base Code:invalid Message:}]

troyhart opened this issue · comments

I am using octopilot 1.0.10 in github actions. When it executes, it successfully pushes the branch to github, but it fails to create the PR, with the following message:

time="2022-04-22T22:06:37Z" level=error msg="Repository update failed" error="failed to create or update Pull Request: failed to create a new Pull Request for repository myriadgenetics/gitops-prod: POST https://api.github.com/repos/myriadgenetics/gitops-prod/pulls: 422 Validation Failed [{Resource:PullRequest Field:base Code:invalid Message:}]" repository=myriadgenetics/gitop
s-prod

Below is the command I am executing and the logging output:

  export BLOX_VERSION=fix-me
  export VERSION=1.0.2059
  export PRODUCT=bloxlet-release-verifier
  octopilot \
  --log-level trace \
  --github-auth-method=token \
  --github-token=*** \
  --repo "myriadgenetics/gitops-stage(merge=true)" \
  --repo "myriadgenetics/gitops-prod" \
  --update "yq(file=${PRODUCT}/kustomization.yaml,expression='.images[] | select(.name == strenv(PRODUCT)) | .newTag',output=.git/prev-version.txt)" \
  --update "yq(file=${PRODUCT}/kustomization.yaml,expression='(.images[] | select(.name == strenv(PRODUCT)) | .newTag) = strenv(VERSION)')" \
  --update "yq(file=${PRODUCT}/kustomization.yaml,expression='(.commonLabels | .version) = strenv(VERSION)')" \
  --git-commit-title 'chore(deps) -- Update bloxlet-release-verifier' \
  --git-commit-body 'TODO -- figure out how to work with the octopilot githubRelease function...use it here' \
  --git-branch-prefix "octopilot-update-${PRODUCT}-" \
  --pr-labels "update-${PRODUCT}" \
  --pr-title "Update ${PRODUCT} to ${VERSION}" \
  --pr-title-update-operation "replace" \
  --pr-body 'TODO -- figure out how to work with the octopilot githubRelease function...use it here' \
  --pr-body-update-operation "prepend" \
  --strategy "reset"
  shell: /usr/bin/bash -e {0}
  env:
    JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.15-10/x64
time="2022-04-22T22:06:35Z" level=trace msg="Parsing updates" updates="[yq(file=bloxlet-release-verifier/kustomization.yaml,expression='.images[] | select(.name == strenv(PRODUCT)) | .newTag',output=.git/prev-version.txt) yq(file=bloxlet-release-verifier/kustomization.yaml,expression='(.images[] | select(.name == strenv(PRODUCT)) | .newTag) = strenv(VERSION)') yq(file=bloxlet-release-verifier/kustomization.yaml,expression='(.commonLabels | .version) = strenv(VERSION)')]"
time="2022-04-22T22:06:35Z" level=debug msg="Updaters ready" updaters="[YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=.images[] | select(.name == strenv(PRODUCT)) | .newTag,output=.git/prev-version.txt,indent=2] YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.images[] | select(.name == strenv(PRODUCT)) | .newTag) = strenv(VERSION),output=,indent=2] YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.commonLabels | .version) = strenv(VERSION),output=,indent=2]]"
time="2022-04-22T22:06:35Z" level=trace msg="Parsing repositories" repos="[myriadgenetics/gitops-stage(merge=true) myriadgenetics/gitops-prod]"
time="2022-04-22T22:06:35Z" level=debug msg="Repositories ready" repositories="[{myriadgenetics gitops-stage map[merge:true]} {myriadgenetics gitops-prod map[]}]"
time="2022-04-22T22:06:35Z" level=trace msg="Starting updates" repositories-count=2
time="2022-04-22T22:06:35Z" level=trace msg="Starting repository update" repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:35Z" level=debug msg="Using 'reset' strategy" repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:35Z" level=trace msg="Cloning git repository" git-reference=HEAD git-url="https://github.com/myriadgenetics/gitops-prod.git" local-path=/tmp/octopilot020886765/myriadgenetics/gitops-prod
time="2022-04-22T22:06:35Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:35Z" level=trace msg="Starting repository update" repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:35Z" level=debug msg="Using 'reset' strategy" repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:35Z" level=trace msg="Cloning git repository" git-reference=HEAD git-url="https://github.com/myriadgenetics/gitops-stage.git" local-path=/tmp/octopilot020886765/myriadgenetics/gitops-stage
time="2022-04-22T22:06:35Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:36Z" level=debug msg="Git repository cloned" git-reference=HEAD git-url="https://github.com/myriadgenetics/gitops-stage.git" local-path=/tmp/octopilot020886765/myriadgenetics/gitops-stage
time="2022-04-22T22:06:36Z" level=trace msg="Looking for existing Pull Requests" labels="[update-bloxlet-release-verifier]" repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:36Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:36Z" level=debug msg="Git repository cloned" git-reference=HEAD git-url="https://github.com/myriadgenetics/gitops-prod.git" local-path=/tmp/octopilot020886765/myriadgenetics/gitops-prod
time="2022-04-22T22:06:36Z" level=trace msg="Looking for existing Pull Requests" labels="[update-bloxlet-release-verifier]" repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:36Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:36Z" level=debug msg="No existing Pull Request found" labels="[update-bloxlet-release-verifier]" repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:36Z" level=trace msg="Using new branch" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k60 repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:36Z" level=debug msg="Switched Git branch" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k60 repository-name=gitops-prod
time="2022-04-22T22:06:36Z" level=trace msg="Running updater" repository=myriadgenetics/gitops-prod updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=.images[] | select(.name == strenv(PRODUCT)) | .newTag,output=.git/prev-version.txt,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="No existing Pull Request found" labels="[update-bloxlet-release-verifier]" repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:36Z" level=trace msg="Using new branch" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k6g repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:36Z" level=debug msg="Switched Git branch" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k6g repository-name=gitops-stage
time="2022-04-22T22:06:36Z" level=trace msg="Running updater" repository=myriadgenetics/gitops-stage updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=.images[] | select(.name == strenv(PRODUCT)) | .newTag,output=.git/prev-version.txt,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="Updater finished" changes=true repository=myriadgenetics/gitops-prod updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=.images[] | select(.name == strenv(PRODUCT)) | .newTag,output=.git/prev-version.txt,indent=2]"
time="2022-04-22T22:06:36Z" level=trace msg="Running updater" repository=myriadgenetics/gitops-prod updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.images[] | select(.name == strenv(PRODUCT)) | .newTag) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="Updater finished" changes=true repository=myriadgenetics/gitops-stage updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=.images[] | select(.name == strenv(PRODUCT)) | .newTag,output=.git/prev-version.txt,indent=2]"
time="2022-04-22T22:06:36Z" level=trace msg="Running updater" repository=myriadgenetics/gitops-stage updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.images[] | select(.name == strenv(PRODUCT)) | .newTag) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="Updater finished" changes=true repository=myriadgenetics/gitops-prod updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.images[] | select(.name == strenv(PRODUCT)) | .newTag) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=trace msg="Running updater" repository=myriadgenetics/gitops-prod updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.commonLabels | .version) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="Updater finished" changes=true repository=myriadgenetics/gitops-stage updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.images[] | select(.name == strenv(PRODUCT)) | .newTag) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=trace msg="Running updater" repository=myriadgenetics/gitops-stage updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.commonLabels | .version) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="Updater finished" changes=true repository=myriadgenetics/gitops-prod updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.commonLabels | .version) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="All updaters finished" repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:36Z" level=debug msg="Git status" repository-name=gitops-prod status=" M bloxlet-release-verifier/kustomization.yaml\n"
time="2022-04-22T22:06:36Z" level=debug msg="Updater finished" changes=true repository=myriadgenetics/gitops-stage updater="YQ[file=bloxlet-release-verifier/kustomization.yaml,expression=(.commonLabels | .version) = strenv(VERSION),output=,indent=2]"
time="2022-04-22T22:06:36Z" level=debug msg="All updaters finished" repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:36Z" level=debug msg="Git status" repository-name=gitops-stage status=" M bloxlet-release-verifier/kustomization.yaml\n"
time="2022-04-22T22:06:36Z" level=debug msg="Git commit" commit=73ea7942bd464dd30b4e1f7f96695077da1f84c6 repository-name=gitops-prod
time="2022-04-22T22:06:36Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:36Z" level=trace msg="Pushing git changes" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k60 force=true repository-name=gitops-prod
time="2022-04-22T22:06:36Z" level=debug msg="Git commit" commit=d73b83c1002000a06fe957abbbf1231c20c9d11f repository-name=gitops-stage
time="2022-04-22T22:06:36Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:36Z" level=trace msg="Pushing git changes" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k6g force=true repository-name=gitops-stage
time="2022-04-22T22:06:37Z" level=debug msg="Git changes pushed" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k6g repository-name=gitops-stage
time="2022-04-22T22:06:37Z" level=trace msg="Creating new Pull Request" repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:37Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:37Z" level=debug msg="Git changes pushed" branch=octopilot-update-bloxlet-release-verifier-c9hidr0ciu9nre2q6k60 repository-name=gitops-prod
time="2022-04-22T22:06:37Z" level=trace msg="Creating new Pull Request" repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:37Z" level=trace msg="Creating github client using auth method \"token\""
time="2022-04-22T22:06:37Z" level=trace msg="Deleting temporary files" path=/tmp/octopilot020886765/myriadgenetics/gitops-stage repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:37Z" level=error msg="Repository update failed" error="failed to create or update Pull Request: failed to create a new Pull Request for repository myriadgenetics/gitops-stage: POST https://api.github.com/repos/myriadgenetics/gitops-stage/pulls: 422 Validation Failed [{Resource:PullRequest Field:base Code:invalid Message:}]" repository=myriadgenetics/gitops-stage
time="2022-04-22T22:06:37Z" level=trace msg="Deleting temporary files" path=/tmp/octopilot020886765/myriadgenetics/gitops-prod repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:37Z" level=error msg="Repository update failed" error="failed to create or update Pull Request: failed to create a new Pull Request for repository myriadgenetics/gitops-prod: POST https://api.github.com/repos/myriadgenetics/gitops-prod/pulls: 422 Validation Failed [{Resource:PullRequest Field:base Code:invalid Message:}]" repository=myriadgenetics/gitops-prod
time="2022-04-22T22:06:37Z" level=info msg="Updates finished" repositories-count=2

I figured out my issue. I had failed to provide the --pr-base-branch argument, which was required since my base branch is main rather than master.