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

ERROR: Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"} #1125

Open
sumanth-sure opened this issue Apr 21, 2022 · 19 comments

Comments

@sumanth-sure
Copy link

sumanth-sure commented Apr 21, 2022

Hi support,

I am not able to get the release tag value from release drafter. I have the following error message in github action

Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"}
{
  name: 'HttpError',
  id: '2187790795',
  status: 422,
  response: {
    url: 'https://********/releases/64928231',
    status: 422,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      connection: 'close',
      'content-length': '193',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 21 Apr 2022 07:24:06 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-oauth-scopes': 'repo',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '*****:62610696',
      'x-oauth-scopes': 'repo, write:packages',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4964',
      'x-ratelimit-reset': '1650528337',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '36',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Validation Failed',
      errors: [
        {
          resource: 'Release',
          code: 'invalid',
          field: 'target_commitish'
        }
      ],
      documentation_url: 'https://docs.github.com/rest/reference/repos#update-a-release'
    }
  },
  request: {
    method: 'PATCH',
    url: 'https://********/releases/64928231',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'probot/12.2.1 octokit-core.js/3.5.1 Node.js/16.13.0 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"body":"## Changelog\\n* No changes\\n","draft":true,"prerelease":false,"name":"v2.0.101 🌈","tag_name":"v2.0.101","target_commitish":"refs/pull/1023/merge"}',
    request: {}
  },

Workflow file

jobs:
  build:
    runs-on: linux
    if: ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
    
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: "0"
          token: ******
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: release-drafter/release-drafter@v5
        id: release
        env:
          GITHUB_TOKEN: ****
      - name: Process new_tag 
        id: process_new_tag
        run: |
            echo "new_tag=${{steps.release.outputs.tag_name}}" >> $GITHUB_ENV
@jetersen
Copy link
Member

delete the draft.
Please check closed issues before posting :)

@sumanth-sure
Copy link
Author

hi @jetersen deleted the draft but it was still no use hence reopened the issue

@jetersen
Copy link
Member

@sumanth-sure whats the on conditions for your github action?

@jetersen jetersen reopened this Apr 22, 2022
@sumanth-sure
Copy link
Author

sumanth-sure commented Apr 22, 2022

on condition

on:
  pull_request:
    types: [opened, synchronize, reopened, edited, labeled, unlabeled]
    paths:
      - x_folder/**

@jetersen
Copy link
Member

I am not sure what your trying to achieve with that workflow?

releaseDrafter is not able to generate tags from a pull requests.

You want to do that on push to a branch.

@sumanth-sure
Copy link
Author

sumanth-sure commented Apr 22, 2022

Apologies for the confusion we use the tag received from the release drafter to bump up the version in PR and commit with version new Version.

  • kustomize edit set image Tag Value From Release Drafter

  • Once We edit the Yaml's inside PR with the latest version then we wish to push the PR To master.

name: Bump version
on:
  pull_request:
    types: [opened, synchronize, reopened, edited, labeled, unlabeled]
    paths:
      - x_folder/**

jobs:
  build:
    runs-on: [self-hosted, Linux]
    if: ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
    
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: "0"
          token: ********
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: release-drafter/release-drafter@v5
        id: release
        env:
          GITHUB_TOKEN: *******
      - name: Process new_tag 
        id: process_new_tag
        run: |
            echo "new_tag=${{steps.release.outputs.tag_name}}" >> $GITHUB_ENV
      - name: "Kustomize Build"
        id: kustomize
        if: steps.release.outputs.tag_name != ''
        uses: ./.github/actions/kube-tools
        with:
          kustomize: "3.5.3"
          command: |
            echo "Setting  image version to ${{env.new_tag}}"
            kustomize edit set image x_docker_image-${{env.new_tag}}
            cd -
      - name: "Commit the version changes"
        id: git-commit
        if: steps.release.outputs.tag_name != ''
        uses: ./.github/actions/auto-commit
        with:
          commit_message: "Updating version to ${{ env.new_tag }}"

In This process we are getting the above error

@sumanth-sure
Copy link
Author

@jetersen any help on this if possible

@jetersen
Copy link
Member

as I said, release drafter is not able to generate drafts from a pull requests.

You could try and point the commitish to master?

      - uses: release-drafter/release-drafter@v5
        id: release
        env:
          GITHUB_TOKEN: *******
        with:
          commitish: master

@SSShooter
Copy link

I ran into this error as well, but it only fail on branches except master.
image

Here's my config:

name: Release Drafter

on:
  push:
    # branches to consider in the event; optional, defaults to all
    branches:
      - master
  # pull_request event is required only for autolabeler
  pull_request:
    # Only following types are handled by the action, but one can default to all as well
    types: [opened, reopened, synchronize]
  # pull_request_target event is required for autolabeler to support PRs from forks
  # pull_request_target:
  #   types: [opened, reopened, synchronize]

permissions:
  contents: read

jobs:
  update_release_draft:
    permissions:
      contents: write # for release-drafter/release-drafter to create a github release
      pull-requests: write # for release-drafter/release-drafter to add label to PR
    runs-on: ubuntu-latest
    steps:
      # (Optional) GitHub Enterprise requires GHE_HOST variable set
      #- name: Set GHE_HOST
      #  run: |
      #    echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

      # Drafts your next Release notes as Pull Requests are merged into "master"
      - uses: release-drafter/release-drafter@v5
        # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
        # with:
        #   config-name: my-config.yml
        #   disable-autolabeler: true
        env:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

JengYoung added a commit to JengYoung/portfolio that referenced this issue Oct 27, 2022
처음 릴리즈에 대한 문제였는지를 확인하고자, PR할 때마다로 바꾸어 테스트한다.

다음 링크를 보니 push로만 가능하다고 한다. 따라서 push에서 계속 테스트해보고, 마지막에 스쿼시해야겠다...!
release-drafter/release-drafter#1125

답변 중:
I am not sure what your trying to achieve with that workflow?
releaseDrafter is not able to generate tags from a pull requests.
You want to do that on push to a branch.
JengYoung added a commit to JengYoung/portfolio that referenced this issue Oct 27, 2022
처음 릴리즈에 대한 문제였는지를 확인하고자, PR할 때마다로 바꾸어 테스트한다.

다음 링크를 보니 push로만 가능하다고 한다. 따라서 push에서 계속 테스트해보고, 마지막에 스쿼시해야겠다...!
release-drafter/release-drafter#1125

답변 중:
I am not sure what your trying to achieve with that workflow?
releaseDrafter is not able to generate tags from a pull requests.
You want to do that on push to a branch.
JengYoung added a commit to JengYoung/portfolio that referenced this issue Oct 27, 2022
뭔가 버저닝이 초기에 잘 되지 않는 현상이 있는 듯하다.
처음 릴리즈에 대한 문제였는지를 확인하고자, PR할 때마다로 바꾸어 테스트한다.

다음 링크를 보니 push로만 가능하다고 한다. 따라서 push에서 계속 테스트해보고, 마지막에 스쿼시해야겠다...!
release-drafter/release-drafter#1125

답변 중:
I am not sure what your trying to achieve with that workflow?
releaseDrafter is not able to generate tags from a pull requests.
You want to do that on push to a branch.

:construction_worker: label name 변경

아무래도 label name에서 문제인지 테스트를 한다.

:test_tube: Release draft default로 변경되는 것인지 테스트
@ducbm051291
Copy link

I met this issue today, any fix yet?

@phatblat
Copy link

phatblat commented Nov 22, 2022

Just started seeing this same error after enabling the autolabeler. Is there a way to limit the action to only updating the draft release on PR merge while still running the autolabeler on the PR?

Run release-drafter/release-drafter@v5
  with:
    config-name: release-drafter.yml
    disable-autolabeler: false
  env:
    GITHUB_TOKEN: ***
"pull_request_target.opened" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)
"pull_request_target.reopened" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)
"pull_request_target.synchronize" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)
"pull_request_target.edited" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)
getditto/ditto: Found 16 releases
{ name: 'event', id: '3526592475' }
getditto/ditto: No draft release found
{ name: 'event', id: '3526592475' }
getditto/ditto: Last release: sdk-release-2.1.0
{ name: 'event', id: '3526592475' }
getditto/ditto: Fetching parent commits of refs/pull/6984/merge since 20[22](https://github.com/getditto/ditto/actions/runs/3526592475/jobs/5914692586#step:2:22)-11-02T23:51:38Z
{ name: 'event', id: '3526592[4](https://github.com/getditto/ditto/actions/runs/3526592475/jobs/5914692586#step:2:4)7[5](https://github.com/getditto/ditto/actions/runs/3526592475/jobs/5914692586#step:2:5)' }
getditto/ditto: Creating new release
{ name: 'event', id: '352[6](https://github.com/getditto/ditto/actions/runs/3526592475/jobs/5914692586#step:2:6)5924[7](https://github.com/getditto/ditto/actions/runs/3526592475/jobs/5914692586#step:2:8)5' }
Error: Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"}
{
  name: 'HttpError',
  id: '35265[9](https://github.com/getditto/ditto/actions/runs/3526592475/jobs/5914692586#step:2:10)2475',
  status: 4[22](https://github.com/getditto/ditto/actions/runs/3526592475/jobs/5914692586#step:2:23),
  response: {
    url: 'https://api.github.com/repos/getditto/ditto/releases',
    status: 422,

Guessing that the separate triggers for updating the draft release vs autolabeler is coming in v6 #1204

@ducbm051291
Copy link

@phatblat Have you resolved this issue yet? I tried many configs but still can't make my workflow work 😢

@h4yfans
Copy link

h4yfans commented Nov 24, 2022

Same here! Auto labeling is working but I started seeing this error.
Let's wait for v6. #1204

@dgokcin
Copy link

dgokcin commented Jan 2, 2023

anyone with a workaround in the last month?

@cbou
Copy link

cbou commented Jan 19, 2023

I had the same issue and have an easy fix. Maybe it can work for you.

New Github repositories do not have "master" as first branch but "main".
Since I just wanted to test the Github action I copied the yml file from the marketplace: https://github.com/marketplace/actions/release-drafter with "master".

The error could be catched and explained ^^

@tekumara
Copy link

tekumara commented Mar 16, 2023

To reiterate the above, it's failing on the pull_request event because the workflow is running in the context of the merge commit. You'll see a log line like which tells you what commitish is and it'll look something like this:

seek-oss/aec: Fetching parent commits of refs/pull/419/merge

To avoid this error, either:

  1. use the pull_request_target event instead. For security reasons, by design this will run the workflow in the context of the base of the pull request, ie: refs/heads/main. Or,
  2. override commitish to point at your master/main branch, e.g. in your workflow yaml:
     - uses: release-drafter/release-drafter@v5
       with:
         commitish: main

@tekumara
Copy link

Maybe the docs could suggest always using pull_request_target to avoid hitting this?

@NARKOZ
Copy link

NARKOZ commented Mar 26, 2023

use the pull_request_target event instead

@tekumara for some reason this doesn't trigger workflow run as with pull_request event.

override commitish to point at your master/main branch

Using commitish option worked. Thanks.

gustavovalverde added a commit to ZcashFoundation/zebra that referenced this issue Sep 25, 2023
Error:
```
Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"}
```

Fixes: release-drafter/release-drafter#1125
mergify bot pushed a commit to ZcashFoundation/zebra that referenced this issue Oct 18, 2023
* ref(workflows): consolidate workflows based on their purpose

This also renames the workflows to make their naming more consistent and adding a naming convention

Fixes: #6166
Fixes: #6167

* fix(workflows): use correct name for patch

* fix(workflow): docker unit tests

* fix(release): validation error

Error:
```
Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"}
```

Fixes: release-drafter/release-drafter#1125

* fix(workflows): reference correct name

* fix: remove extra workflow

* fix(workflows): use larger runners

* fix(workflow): remove code already in docker unit-test

* fix(unit-tests): start zebra the right way

* fix: typo in patch name

* chore: move job to logical order

* imp(workflows): use better name for gcp tests

* add: missing merge changes

* chore: use better name for find-disks

* fix(ci): use the `entrypoint.sh` to change the Network

* fix(ci): add missing `ZEBRA_CONF_PATH` variable

* fix(ci): allow to build the entrypoint file with testnet

* fix(entrypoint): allow to create a dir and file with a single variable

* refactor: test config file in CI and CD with a reusable workflow

* fix(ci): wrong name used

* fix(ci): use checkout

* fix(ci): improve docker config tests

* fix(ci): use better name for protection rules

* Fix changed workflow file name in docs patch file

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Arya <aryasolhi@gmail.com>

* fix(cd): depend on file tests

* fix(docs): adapt to new workflow name

* fix: revert test coverage on CD

* chore: reduce diff

* fix(ci): allow using variable images for reusable workflows

* fix(dockerfile): use variables or default for config path and file

* fix(entrypoint): if `$ZEBRA_CONF_PATH` is set, do not override it

* Fix patch job names and remove failure job testnet dependencies

---------

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Arya <aryasolhi@gmail.com>
mergify bot pushed a commit to ZcashFoundation/zebra that referenced this issue Oct 19, 2023
* ref(workflows): consolidate workflows based on their purpose

This also renames the workflows to make their naming more consistent and adding a naming convention

Fixes: #6166
Fixes: #6167

* fix(workflows): use correct name for patch

* fix(workflow): docker unit tests

* fix(release): validation error

Error:
```
Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"}
```

Fixes: release-drafter/release-drafter#1125

* fix(workflows): reference correct name

* fix: remove extra workflow

* fix(workflows): use larger runners

* fix(workflow): remove code already in docker unit-test

* fix(unit-tests): start zebra the right way

* fix: typo in patch name

* chore: move job to logical order

* imp(workflows): use better name for gcp tests

* ref(workflow): use a single job to run GCP tests

* fix(ci): do not format existing cached states if required

* test: wait for the instance to be fully ready

* fix(ci): use correct logic before formating

* fix: use correct condition

* fix: get more information

* fix(ci): use better shell handling and upgrade OS

* fix(ci): use better approach

* fix: `$DISK_OPTION` is not being correctly passed

* fix typo

* fix: more typos

* fix: use busybox

* fix: mount Docker volume at run and not before

* fix: use correct condition and simpler while

* add: missing merge changes

* chore: use better name for find-disks

* fix(ci): use the `entrypoint.sh` to change the Network

* fix(ci): add missing `ZEBRA_CONF_PATH` variable

* fix(ci): considerate new updates to jobs

* fix(ci): allow to build the entrypoint file with testnet

* fix(entrypoint): allow to create a dir and file with a single variable

* fix(ci): add missing jobs to `failure-issue`

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* fix(ci): use better comment

* refactor: test config file in CI and CD with a reusable workflow

* fix(ci): wrong name used

* fix(ci): use checkout

* fix(ci): improve docker config tests

* fix(ci): use better name for protection rules

* chore: missing merge conflicts

---------

Co-authored-by: teor <teor@riseup.net>
@justinmchase
Copy link

If I change it to pull_request_target it no longer runs at all, does anyone have a more complete example of how to use that trigger?

KeisukeShima added a commit to KeisukeShima/release-test that referenced this issue Mar 1, 2024
kaoru2010 added a commit to kaoru2010/github-actions-demo00 that referenced this issue Mar 2, 2024
kaoru2010 added a commit to kaoru2010/github-actions-demo00 that referenced this issue Mar 2, 2024
shenxianpeng added a commit to cpp-linter/.github that referenced this issue Mar 8, 2024
damyan added a commit to ironcore-scrapyard/test-actions that referenced this issue Apr 11, 2024
damyan added a commit to ironcore-scrapyard/test-actions that referenced this issue Apr 11, 2024
anarion80 added a commit to mariusz-ostoja-swierczynski/tech-controllers that referenced this issue Apr 16, 2024
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