Changelog api raised error when don't mentioning the "from" and "to"

Changelog api return failed message

I’m trying to use Changelog api of gitlab, as in the documentation stated the POST request must be like this:

curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG"

I pass CI_COMMIT_TAG too in case of using terminal :)
but every time I use this curl command via the command line (inside git directory) or via the pipeline with the following job

    - job: auto_release_notes
      artifacts: true
  stage: release
  - if: '$CI_COMMIT_TAG =~ /^v?\d+\.\d+\.\d+$/'
    - apk add ca-certificates curl
    - 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG"'
    tag_name: '$CI_COMMIT_TAG'
    name: 'Release $CI_COMMIT_TAG'
    ref: '$CI_COMMIT_SHA'

the result is successful pipeline with failed message: {"message":"Failed to generate the changelog: The commit start range is unspecified, and no previous tag could be found to use instead"}
but if I mention the “from” and “to” keywords in curl command the result will be something that it should be

curl -kH "PRIVATE-TOKEN: $CI_API_TOKEN" -X POST "$CI_API_V4_URL/$CI_PROJECT_ID/repository/changelog?version=v1.0.0&from=f4c5f33ce88&to=c7f62db399da3"

is there anything that I missed?
Thanks for taking the time to be thorough in your request, it really helps! :blush:

Hey, having the same issue, Did you by any chance found a solution to this?

Hi @nikos.floros
Yeah I found the problem, (at least for me) the problem was: the changlog api somehow cannot handle the tag name starting with “v” I removed it and test the pipeline multiple time and the changelog api worked perfectly. But I’m not sure this is a bug or something else (as it seems nobody does not have any complaints about it.

1 Like

Thank you so much for getting back to me, will try it out and hope it works!

This is a known bug, please see Cannot create changelog with changelog-API when release starts with a v for more details. It should hopefully be fixed as part of GitLab %16.10.