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

KeyError: 'apiurl_aliases' #1439

Closed
andreas-schwab opened this issue Oct 22, 2023 · 6 comments · Fixed by #1440
Closed

KeyError: 'apiurl_aliases' #1439

andreas-schwab opened this issue Oct 22, 2023 · 6 comments · Fixed by #1440
Labels

Comments

@andreas-schwab
Copy link
Member

$ osc config https://api.opensuse.org --delete aliases
Traceback (most recent call last):
File "/usr/bin/osc", line 11, in
load_entry_point('osc==1.4.3', 'console_scripts', 'osc')()
File "/usr/lib/python3.6/site-packages/osc/babysitter.py", line 226, in main
sys.exit(run(commandline.OscMainCommand()))
File "/usr/lib/python3.6/site-packages/osc/babysitter.py", line 69, in run
prg.main(argv)
File "/usr/lib/python3.6/site-packages/osc/commandline.py", line 545, in main
cmd.run(args)
File "/usr/lib/python3.6/site-packages/osc/commandline.py", line 241, in run
cmd.run(args)
File "/usr/lib/python3.6/site-packages/osc/commandline.py", line 489, in run
self.func(args.command, args, *args.positional_args)
File "/usr/lib/python3.6/site-packages/osc/commandline.py", line 9863, in do_config
opt, newval = conf.config_set_option(section, opt, ' '.join(val), delete=opts.delete, update=True, creds_mgr_descr=creds_mgr_descr)
File "/usr/lib/python3.6/site-packages/osc/conf.py", line 1620, in config_set_option
section = config['apiurl_aliases'].get(section, section)
File "/usr/lib/python3.6/site-packages/osc/conf.py", line 148, in getitem
return self.extra_fields[name]
KeyError: 'apiurl_aliases'

@jengelh
Copy link
Contributor

jengelh commented Oct 22, 2023

Also happens adding aliases:

12:06 a4:../telephony/linphone $ osc build
Building linphone.spec for openSUSE_Tumbleweed/x86_64
[...]
The build root needs packages from project 'network:telephony'.
Note that malicious packages can compromise the build result or even your system.
Would you like to ...
0 - quit (default)
1 - always trust packages from 'network:telephony'
2 - trust packages just this time
? 1
adding 'network:telephony' to oscrc: ['https://api.opensuse.org']['trusted_prj']
Traceback (most recent call last):
  File "/usr/bin/osc", line 33, in <module>
    sys.exit(load_entry_point('osc==1.4.3', 'console_scripts', 'osc')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/babysitter.py", line 226, in main
    sys.exit(run(commandline.OscMainCommand()))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/babysitter.py", line 69, in run
    prg.main(argv)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 545, in main
    cmd.run(args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 241, in run
    cmd.run(args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 489, in run
    self.func(args.command, args, *args.positional_args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 7349, in do_build
    return osc_build.main(self.get_api_url(), store, opts, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/build.py", line 1125, in main
    check_trusted_projects(apiurl, [i for i in bi.projects.keys() if not i == prj])
  File "/usr/lib/python3.11/site-packages/osc/build.py", line 580, in check_trusted_projects
    conf.config_set_option(apiurl, 'trusted_prj', ' '.join(trusted))
  File "/usr/lib/python3.11/site-packages/osc/conf.py", line 1620, in config_set_option
    section = config['apiurl_aliases'].get(section, section)
              ~~~~~~^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/conf.py", line 148, in __getitem__
    return self.extra_fields[name]
           ~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'apiurl_aliases'

@SchoolGuy
Copy link
Contributor

Can confirm.

┬─[enno@tower:~/S/E/h/python-sqlite3-to-mysql]─[15:57:53]
╰─>$ osc version
1.4.3

@mlewissmith
Copy link

This appears to affect any attempt to write/change any config values in [$apiurl] sections, but not the [general] section

$ osc config general build-jobs 1
'general': 'build-jobs' is set to '1'

but

$ osc config $APIURL --changepassword
...
KeyError: 'apiurl_aliases'

@cpanel-hans
Copy link

I get the same error when running osc config internal user
...
KeyError: 'apiurl_aliases'

Broke for me when I updated from osc-1.2.0-372.1.noarch to osc-1.4.3-383.1.noarch

@drmuey
Copy link

drmuey commented Oct 23, 2023

9067a80 seems relevant, was in v1.4.2 ee5a1c4

@pallaswept
Copy link

pallaswept commented Oct 28, 2023

Same with copypac (my.private.api.url is edited in there for my privacy and is a real URL which does work with other OSC commands):

osc -A api.opensuse.org copypac -t my.private.api.url $PROJECT ffnvcodec $PROJECT
Traceback (most recent call last):
  File "/usr/bin/osc", line 33, in <module>
    sys.exit(load_entry_point('osc==1.4.3', 'console_scripts', 'osc')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/babysitter.py", line 226, in main
    sys.exit(run(commandline.OscMainCommand()))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/babysitter.py", line 69, in run
    prg.main(argv)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 545, in main
    cmd.run(args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 241, in run
    cmd.run(args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 489, in run
    self.func(args.command, args, *args.positional_args)
  File "/usr/lib/python3.11/site-packages/osc/commandline.py", line 3873, in do_copypac
    tgt_apiurl = conf.config['apiurl_aliases'].get(opts.to_apiurl, opts.to_apiurl)
                 ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/osc/conf.py", line 148, in __getitem__
    return self.extra_fields[name]
           ~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'apiurl_aliases'

I get the same thing if I use the alias or fully specify the URL. I tried the patch mentioned that hopefully fixes this and indeed I didn't get the same error, but it still didn't work:

osc -A api.opensuse.org copypac -t my.private.api.url $PROJECT ffnvcodec $PROJECT
Sending meta data...
Server returned an error: HTTP Error 405: Method Not Allowed

Which might be a different issue and need a different case logged, or might be a failure of the fix, I can't say for sure.

Edit: I was able to get the copypac to work by cd'ing to the local copy of the project, and specifying the alias (rather than the URL) there, with the fix from #1440 in place:

osc copypac -t private $PROJECT ffnvcodec $PROJECT
Sending meta data...
Copying files...
  _service
  ffnvcodec.changes
  ffnvcodec.spec
  nv-codec-headers-11.1.5.2.tar.xz
Done.

So it looks like #1440 fixes this and my copypac syntax was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants