#594 Cannot create branch request
Closed: Fixed by maha. Opened by maha.

I have created a token with all ACLs:

 [mh@toolbx libgsasl]$ fedpkg set-pagure-token 
Input the token: 
updating config '/home/mh/.config/rpkg/fedpkg.conf'
 [mh@toolbx libgsasl]$ cat /home/mh/.config/rpkg/fedpkg.conf
[fedpkg.pagure]
token = xxxxx
 [mh@toolbx libgsasl]$ fedpkg -d -v  --user maha request-branch epel10
Creating repo object from /var/home/mh/box/fedora/git/libgsasl
Pagure API request: https://src.fedoraproject.org/api/0/rpms/libgsasl/git/branches
Pagure API response: '{'branches': ['el4', 'el5', 'el6', 'epel7', 'epel8', 'epel8-playground', 'epel9', 'f10', 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f20', 'f21', 'f22', 'f23', 'f24', 'f25', 'f26', 'f27', 'f28', 'f29', 'f30', 'f31', 'f32', 'f33', 'f34', 'f35', 'f36', 'f37', 'f38', 'f39', 'f40', 'f41', 'f42', 'f7', 'f8', 'f9', 'fc6', 'main', 'rawhide'], 'default': 'rawhide', 'total_branches': 46}'
Pagure API response: '{'error': 'Invalid or expired token. Please visit https://pagure.io/settings#nav-api-tab to get or renew your API token.', 'error_code': 'EINVALIDTOK', 'errors': 'Invalid token'}'
Could not execute request_branch: The following error occurred while creating a new issue in Pagure: Invalid or expired token. Please visit https://pagure.io/settings#nav-api-tab to get or renew your API token.
For invalid or expired tokens please set a new token in your user configuration with:
    fedpkg set-pagure-token <token>
Traceback (most recent call last):
  File "/usr/bin/fedpkg", line 33, in <module>
    sys.exit(load_entry_point('fedpkg==1.45', 'console_scripts', 'fedpkg')())
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/fedpkg/__main__.py", line 84, in main
    sys.exit(client.args.command())
             ~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/fedpkg/cli.py", line 1103, in request_branch
    self._request_branch(
    ~~~~~~~~~~~~~~~~~~~~^
        logger=self.log,
        ^^^^^^^^^^^^^^^^
    ...<10 lines>...
        anongiturl=self.cmd.anongiturl,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/fedpkg/cli.py", line 1251, in _request_branch
    print(new_pagure_issue(
          ~~~~~~~~~~~~~~~~^
        logger, pagure_url, pagure_token, ticket_title, ticket_body,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        name))
        ^^^^^
  File "/usr/lib/python3.13/site-packages/fedpkg/utils.py", line 98, in new_pagure_issue
    raise rpkgError(base_error_msg.format(rv_error))
pyrpkg.errors.rpkgError: The following error occurred while creating a new issue in Pagure: Invalid or expired token. Please visit https://pagure.io/settings#nav-api-tab to get or renew your API token.
For invalid or expired tokens please set a new token in your user configuration with:
    fedpkg set-pagure-token <token>

I re-created the token many times and I fail to request a branch.

]$ rpm -qi fedpkg
Name        : fedpkg
Version     : 1.45
Release     : 5.fc41
Architecture: noarch
Install Date: Mon 24 Feb 2025 05:22:19 PM CET
Group       : Unspecified
Size        : 325608
License     : GPL-2.0-or-later
Signature   : RSA/SHA256, Wed 18 Sep 2024 07:17:57 AM CEST, Key ID d0622462e99d6ad1
Source RPM  : fedpkg-1.45-5.fc41.src.rpm
Build Date  : Wed 18 Sep 2024 07:02:12 AM CEST
Build Host  : buildvm-s390x-04.s390.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://pagure.io/fedpkg
Bug URL     : https://bugz.fedoraproject.org/fedpkg
Summary     : Fedora utility for working with dist-git
Description :
Provides the fedpkg command for working with dist-git

Hi @maha,
I tested the issue with the same fedpkg's version and the same input.
First, I deliberately put a wrong token and I got the same response.
Then I return back to my original token and I got.

$ fedpkg -d -v --user maha request-branch epel10
Creating repo object from /repo/libgsasl
Pagure API request: https://src.fedoraproject.org/api/0/rpms/libgsasl/git/branches
Pagure API response: '{'branches': ['el4', 'el5', 'el6', 'epel7', 'epel8', 'epel8-playground', 'epel9', 'f10', 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f20', 'f21', 'f22', 'f23', 'f24', 'f25', 'f26', 'f27', 'f28', 'f29', 'f30', 'f31', 'f32', 'f33', 'f34', 'f35', 'f36', 'f37', 'f38', 'f39', 'f40', 'f41', 'f42', 'f7', 'f8', 'f9', 'fc6', 'main', 'rawhide'], 'default': 'rawhide', 'total_branches': 46}'
Pagure API response: '{'issue': {'assignee': None, 'blocks': [], 'close_status': None, 'closed_at': None, 'closed_by': None, 'comments': [], 'content': '```\n{\n "action": "new_branch",\n "branch": "epel10",\n "namespace": "rpms",\n "repo": "libgsasl",\n "create_git_branch": true\n}\n```', 'custom_fields': [], 'date_created': '1740523169', 'depends': [], 'full_url': 'https://pagure.io/releng/fedora-scm-requests/issue/72705', 'id': 72705, 'last_updated': '1740523169', 'milestone': None, 'priority': None, 'private': False, 'related_prs': [], 'status': 'Open', 'tags': [], 'title': 'New Branch "epel10" for "rpms/libgsasl"', 'user': {'full_url': 'https://pagure.io/user/onosek', 'fullname': 'Ondrej Nosek', 'name': 'onosek', 'url_path': 'user/onosek'}}, 'message': 'Issue created'}'
https://pagure.io/releng/fedora-scm-requests/issue/72705

of course it sent a request with my name and it was immediately refused - I am not a maintainer of this package. But I don't see any obvious reason why it failed to you.

My token has just one (minimum required) ACL - issue_create.

Screenshot_2025-02-25_23-49-02.png

Later, I tested it with all ACLs set, and it worked too.
https://pagure.io/releng/fedora-scm-requests/issue/72717

Maybe some temporary outage ...

Somehow it worked for libgsasl suddenly.

But now it again fails and I am pretty sure I have the right token and I have also waited more than a day since last using the token:

fedpkg-cli.png

Is there a way to get more output with what headers etc. fedpkg tries to make the call?
fedpkg-api.png

Regarding the headers, the request can be tested in the console with this code:

url = "https://pagure.io/api/0/releng/fedora-scm-requests/new_issue"
headers = {'Authorization': 'token UCIVAFF.......CHANGE_THE_TOKEN_KEEP_the_token_str_at_the_beginning', 'Accept': 'application/json', 'Content-Type': 'application/json'}
payload = '{"title": "New Branch \\"epel10\\" for \\"rpms/google-authenticator\\"", "issue_content": "```\\n{\\n \\"action\\": \\"new_branch\\",\\n \\"branch\\": \\"epel10\\",\\n \\"namespace\\": \\"rpms\\",\\n \\"repo\\": \\"google-authenticator\\",\\n \\"create_git_branch\\": true\\n}\\n```"}'
requests.post(url, headers=headers, data=payload, timeout=60)

It still worked for me, I just can't create the branch by myself

You can request the branch manually, but I understand fedpkg should be working.
https://pagure.io/releng/fedora-scm-requests/issue/72908
If it is not caused by a temporary outage, then I suspect something inside the Pagure itself or Fedora account settings. I don't have reports from other users about this behaviour.

Ohhhh sorry... now when testing it and seeing the url where the request must be submitted, I realize: I had a token for src.fedoraproject.org and not pagure.io

With a token from pagure.io it just works fine.

Sorry for this, this is a bit embarassing...

Metadata Update from @maha:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

But what I don't understand: fedpkg says in the debug src.fedoraproject.org, but it works with the token fro pagure.io, but not the one taken from src.fedoraproject.org - so this is super confusing....

There are 2 different tokens:

  • pagure.io | set by fedpkg set-pagure-token | used for requesting branches or repos
  • src.fedoraproject.org | set by fedpkg set-distgit-token | used for forking repositories
$ fedpkg set-pagure-token --help
usage: fedpkg set-pagure-token [-h]
Updates the fedpkg.pagure API token in ~/.config/rpkg/fedpkg.conf file. Tokens are of length 64 and contain only uppercase and numerical values. The new API token. Can be generated
at: https://pagure.io/settings/token/new
options:
  -h, --help  show this help message and exit

The command line "help" mentions the correct address for requesting the corresponding token. Unfortunately, these systems are different (sources, dist-git) and can't have a common token. What do you think might improve this "super confusing" situation?

So I think what confused me: I work with packages on a pagure instance on src.fedoraproject.org - however to request branches I need to create a PR on another pagure instance on pagure.io

Fedpkg tells me to set a pagure token, so I assumed: I am working with packages, so it needs a token from src.fedoraproject.org

But well, since these things might change anyway, I don't think it's worth at the moment to further investigate it.

Thank you for all the explanations and sorry for the confusion on my side.

Metadata