$ rpm -q centpkg centpkg-0.6.2-1.fc33.noarch
I was trying to create a fork:
$ centpkg fork Could not execute do_distgit_fork: The following error occurred while creating a new fork: {"message":"401 Unauthorized"} For invalid or expired token refer to "centpkg fork -h" to set a token in your user configuration.
I've put my local configuration as recommended by the help message:
$ centpkg fork -h usage: centpkg fork [-h] Create a new fork of the current repository Before the operation, you need to generate an API token at https://gitlab.com/-/profile/personal_access_tokens, select the relevant scope(s) and save it in your local user configuration located at ~/.config/rpkg/centpkg.conf. For example: [centpkg.distgit] token = <api_key_here> Below is a basic example of the command to fork a current repository: centpkg fork Operation requires username (GITLAB_ID). by default, current logged username is taken. It could be overridden by reusing an argument: centpkg --user GITLAB_ID fork optional arguments: -h, --help show this help message and exit
But it would still fail:
$ centpkg --debug -v fork Creating repo object from /home/vashirov/src/centos/389-ds-base Pagure API response: '{'message': '401 Unauthorized'}' Traceback (most recent call last): File "/usr/bin/centpkg", line 19, in <module> main() File "/usr/lib/python3.9/site-packages/centpkg/__main__.py", line 91, in main sys.exit(client.args.command()) File "/usr/lib/python3.9/site-packages/centpkg/cli.py", line 91, in do_distgit_fork ret = do_fork( File "/usr/lib/python3.9/site-packages/centpkg/utils.py", line 74, in do_fork raise rpkgError(base_error_msg.format(rv.text)) pyrpkg.errors.rpkgError: The following error occurred while creating a new fork: {"message":"401 Unauthorized"} For invalid or expired token refer to "centpkg fork -h" to set a token in your user configuration.
(also note it still refers to Pagure API)
Turns out I had to modify system config file at /etc/rpkg/centpkg.conf so that my token would be picked up.
/etc/rpkg/centpkg.conf
Correct, by default we use the system level configuration file, this behavior can be overwritten by using -c $configfile.
-c $configfile
That said, I think we need to updated the help text and look for the config file in .config first if possible.
Any local config needs to override the system config, but that doesn't necessarily mean it should be read first.
Anyway, this is blocking multiple users and needs to get fixed ASAP.
And, in fact, using --config ~/.config/rpkg/centpkg.conf results in an error because that config lacks other needed information:
--config ~/.config/rpkg/centpkg.conf
Traceback (most recent call last): File "/usr/lib64/python3.9/configparser.py", line 789, in get value = d[option] File "/usr/lib64/python3.9/collections/__init__.py", line 941, in __getitem__ return self.__missing__(key) # support subclasses that define __missing__ File "/usr/lib64/python3.9/collections/__init__.py", line 933, in __missing__ raise KeyError(key) KeyError: 'apibaseurl' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/centpkg/utils.py", line 142, in config_get_safely return config.get(section, option) File "/usr/lib64/python3.9/configparser.py", line 792, in get raise NoOptionError(option, section) configparser.NoOptionError: No option 'apibaseurl' in section: 'centpkg.distgit' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/centpkg", line 19, in <module> main(sig=False) File "/usr/lib/python3.9/site-packages/centpkg/__main__.py", line 63, in main client = centpkg.cli.centpkgClient(config) File "/usr/lib/python3.9/site-packages/centpkg/cli.py", line 31, in __init__ self.setup_centos_subparsers() File "/usr/lib/python3.9/site-packages/centpkg/cli.py", line 34, in setup_centos_subparsers self.register_do_fork() File "/usr/lib/python3.9/site-packages/centpkg/cli.py", line 39, in register_do_fork distgit_api_base_url = config_get_safely(self.config, distgit_section, "apibaseurl") File "/usr/lib/python3.9/site-packages/centpkg/utils.py", line 150, in config_get_safely raise rpkgError("{0}\n{1}".format(msg, hint)) pyrpkg.errors.rpkgError: Missing option 'apibaseurl' in the section 'centpkg.distgit' of the config file. First (if possible), refer to the help of the current command (-h/--help). There also might be a new version of the config after upgrade. Hint: you can check if you have 'centpkg.conf.rpmnew' or 'centpkg.conf.rpmsave' in the config directory. If yes, try to merge your changes to the config with the maintainer provided version (or replace centpkg.conf file with 'centpkg.conf.rpmnew').
As a workaround, the user can copy /etc/rpkg/centpkg.conf into ~/.config/rpkg/centpkg.conf, add the API token and then run centpkg --config~/.config/rpkg/centpkg.conf` but this is not a great solution (and it means decentralizing the main part of the configuration)
~/.config/rpkg/centpkg.conf
centpkg --config
Are you saying we should "merge" the two configs files? The local config file overwriting any defaults/system wise configuration?
We could add a command, something like bootstrap, to create the initial config file locally or copy the config file over to the home directory as well in the rpm spec file.
bootstrap
I also think it needs to handle those errors better, showing a proper error message, such as api token missing, those raw python exceptions errors are not ideal...
I can work on it but I wanted to get to an agreement on how to solve the issue.
I think we should take the same approach as fedpkg, reading the global config and then reading the user config, effectively merging the two together.
I've opened #26 to address this.
#26 has been merged and released as part of 0.6.3.
Metadata Update from @carlwgeorge: - Issue status updated to: Closed (was: Open)
Log in to comment on this ticket.