release-drafter: ERROR: Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"}

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

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 14
  • Comments: 19 (4 by maintainers)

Commits related to this issue

Most upvoted comments

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
    

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

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.

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

I met this issue today, any fix yet?