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

Wrong Copr-Error-Data header formatting #3584

Open
m-blaha opened this issue Jan 13, 2025 · 1 comment
Open

Wrong Copr-Error-Data header formatting #3584

m-blaha opened this issue Jan 13, 2025 · 1 comment
Labels

Comments

@m-blaha
Copy link

m-blaha commented Jan 13, 2025

Dnf copr client expects Base64 encoded string in the Copr-Error-Data response header if an incorrect project/architecture was attempted to download.
Currently the header contains:

Copr-Error-Data: b'eyJhdmFpbGFibGUgY2hyb290cyI6IFsiZXBlbC0xMC1hYXJjaDY0IiwgImVwZWwtOS1hYXJjaDY0Il19'

with incorrect leading b' and trailing '.

The error causes dnf4 copr plugin to fail with traceback:

❯ sudo dnf4 copr enable mblaha/coprtest -y
Enabling a Copr repository. Please note that this repository is not part
of the main distribution, and quality may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://docs.pagure.org/copr.copr/user_documentation.html#what-i-can-build-in-copr>,
and packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/dnf-plugins/copr.py", line 503, in _download_repo
    response = urlopen(self.copr_url + api_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/urllib/request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib64/python3.12/urllib/request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: NOT FOUND

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/dnf4", line 57, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.12/site-packages/dnf/cli/main.py", line 208, in user_main
    errcode = main(args)
              ^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/dnf/cli/main.py", line 67, in main
    return _main(base, args, cli_class, option_parser_class)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/dnf/cli/main.py", line 106, in _main
    return cli_run(cli, base)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/dnf/cli/main.py", line 122, in cli_run
    cli.run()
  File "/usr/lib/python3.12/site-packages/dnf/cli/cli.py", line 1067, in run
    return self.command.run()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/dnf-plugins/copr.py", line 314, in run
    self._download_repo(project_name, repo_filename)
  File "/usr/lib/python3.12/site-packages/dnf-plugins/copr.py", line 514, in _download_repo
    error_data_decoded = base64.b64decode(error_data)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/base64.py", line 88, in b64decode
    return binascii.a2b_base64(s, strict_mode=validate)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
binascii.Error: Invalid base64-encoded string: number of data characters (81) cannot be 1 more than a multiple of 4

@FrostyX
Copy link
Member

FrostyX commented Jan 14, 2025

Thank you for the report @m-blaha,
I can confirm that this is easily reproducible by sudo dnf4 copr enable mblaha/coprtest -y

@praiskup praiskup moved this from Needs triage to In 3 months in CPT Kanban Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In 3 months
Development

No branches or pull requests

2 participants