#604 AlreadyUploadedError when package has no sources
Closed: Fixed 2 years ago by drumian. Opened 2 years ago by frostyx.

When trying to import a package with no sources that should be uploaded into the lookaside cache, it fails with AlreadyUploadedError:

Traceback (most recent call last):
  File "/opt/copr/dist-git/copr_dist_git/package_import.py", line 230, in import_package
    commands.upload(upload_files, replace=True)
  File "/usr/lib/python3.10/site-packages/pyrpkg/__init__.py", line 2916, in upload
    raise AlreadyUploadedError('File already uploaded')
pyrpkg.errors.AlreadyUploadedError: File already uploaded

A minimal reproducer is a package like this:

Name:       pkg-no-sources
Version:    1.0
Release:    1%{?dist}
Summary:    Testing spec file
License:    GPLv2
URL:        https://pagure.io/copr/copr

%description
Test spec file that doesn't have any sources that should be uploaded into
the lookaside cache

%files

%build

%changelog
* Sun Feb 06 2022 Jakub Kadlcik <frostyx@email.cz> - 1.0-1
- Initial version

But we discovered the bug in Copr while building a real package:
https://download.copr-dev.fedorainfracloud.org/results/frostyx/podman4/srpm-builds/02906316/containers-common-1-43.src.rpm

This issue started happening after upgrading to python3-rpkg-1.63-5. Up until now, we were using python3-rpkg-1.62-6 and skipped every release in between because of #588, so I am not sure which exact release introduced it.


I tried to reproduce this error using both provided minimal package and real package. However, I was unable to get this error while having the same version of rpkg.

Could you provide more information about getting this error, please?

Just to add ...
@drumian created a new srpm with your minimal specfile:

mkdir pkg-no-sources
cd pkg-no-sources
git init
vim pkg-no-sources.spec
fedpkg --release f34 srpm

and then he did fedpkg import with newly generated srpm in a clean repository. There wasn't any exception raised. Was your scenario different?

Hello @drumian and @onosek, I am sorry, that I didn't provide a better reproducer.

You started good here

mkdir pkg-no-sources
cd pkg-no-sources
git init
vim pkg-no-sources.spec
fedpkg --release f34 srpm

But instead of fedpkg import you need to run the following code:

from pyrpkg import Commands 
commands = Commands(
    path=".", 
    lookaside="", 
    lookasidehash="md5", 
    lookaside_cgi="", 
    gitbaseurl="foo", 
    anongiturl="", 
    branchre="", 
    kojiprofile="", 
    build_client="",
)
upload_files = commands.import_srpm("./pkg-no-sources-1.0-1.fc34.src.rpm")

# This line triggers the AlreadyUploadedError
commands.upload(upload_files, replace=True)

Hello @frostyx!

Thank you very much for clarification. I was able to reproduce it using your script here.

I was able to reproduce it using your script here.

Perfect. Of course in my code, the upload_files is an empty list, so I could easily add a condition and run commands.upoad only if there are some files. But I think the AlreadyUploadedError in this case is a bug.

The previous behavior was that commands.upload did nothing, but if you want to throw an exception that there are no sources, that is fine with me as well, I will adjust my code accordingly. Pick what solution you prefer :-)

Metadata Update from @onosek:
- Issue set to the milestone: 1.65

2 years ago

Login to comment on this ticket.

Metadata