Skip to content

UnboundLocalError in build_rpm() method; builder referenced in finally block, but not guaranteed to have been defined #4147

@mulkieran

Description

@mulkieran

I have evidence of this problem from looking at some Packit logs.

Here is the report:

Traceback (most recent call last):
  File "/usr/bin/copr-rpmbuild", line 242, in build_rpm
    distgit.produce_sources()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.14/site-packages/copr_rpmbuild/providers/distgit.py", line 36, in produce_sources
    helpers.run_cmd(["dist-git-client", "sources"], cwd=self.clone_to)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/site-packages/copr_rpmbuild/helpers.py", line 76, in run_cmd
    raise RuntimeError(result.stderr)
RuntimeError: INFO: Reading stdout from command: git rev-parse --abbrev-ref HEAD
INFO: Reading stdout from command: git rev-parse HEAD
INFO: Reading sources specification file: sources
INFO: Downloading libcryptsetup-rs-0.15.0.crate
INFO: Reading stdout from command: curl --help all
INFO: Calling: curl -H Pragma: -o libcryptsetup-rs-0.15.0.crate --location --connect-timeout 60 --retry 3 --retry-delay 10 --remote-time --show-error --fail --retry-all-errors https://copr-dist-git.fedorainfracloud.org/repo/pkgs/packit/stratis-storage-libcryptsetup-rs-468/rust-libcryptsetup-rs/libcryptsetup-rs-0.15.0.crate/md5/eccc5748f00b76982f50ade7d778a0bd/libcryptsetup-rs-0.15.0.crate
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  285k    0  285k    0     0  4447k      0 --:--:-- --:--:-- --:--:-- 4460k
INFO: Reading stdout from command: md5sum libcryptsetup-rs-0.15.0.crate
ERROR: Check-sum de311885365dcc2e547889b6eb9b31ac is wrong, expected: eccc5748f00b76982f50ade7d778a0bd

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/copr-rpmbuild", line 109, in main_daemon
    action(args, config)
    ~~~~~~^^^^^^^^^^^^^^
  File "/usr/bin/copr-rpmbuild", line 250, in build_rpm
    builder.archive_configs()
    ^^^^^^^
UnboundLocalError: cannot access local variable 'builder' where it is not associated with a value
Traceback (most recent call last):
  File "/usr/bin/copr-rpmbuild", line 242, in build_rpm
    distgit.produce_sources()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.14/site-packages/copr_rpmbuild/providers/distgit.py", line 36, in produce_sources
    helpers.run_cmd(["dist-git-client", "sources"], cwd=self.clone_to)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/site-packages/copr_rpmbuild/helpers.py", line 76, in run_cmd
    raise RuntimeError(result.stderr)
RuntimeError: INFO: Reading stdout from command: git rev-parse --abbrev-ref HEAD

The original cause of the problem that lead to entering the finally block is a discrepancy between the expected and actual checksums of a downloaded crate. This is really a problem, and not, as far as I can tell due to a partial download of the crate. When I do a download I get the same checksum, but the crate does not seem to corrupted as I can untar it. I'll report that problem separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions