Fix 500 in public#binary_packages for scmsync project packages - #20251
Open
Jarvis-J-Jacob wants to merge 2 commits into
Open
Fix 500 in public#binary_packages for scmsync project packages#20251Jarvis-J-Jacob wants to merge 2 commits into
Jarvis-J-Jacob wants to merge 2 commits into
Conversation
hennevogel
requested changes
Sep 2, 2026
Packages of scmsync projects live in the project's git repository, not in the database. #binary_packages guarded access with check_package_access (use_source: false) and then looked @pkg up with a plain DB query, which returns nil for a package of an scmsync project. @pkg stayed nil and the action crashed at @pkg.project.repositories with "undefined method 'project' for nil" -> HTTP 500. Look @pkg up with Package.get_by_project_and_name(use_source: false, follow_project_scmsync_links: true) instead. It resolves the same database packages the previous lookup did, and additionally builds a read-only Package from the backend package meta for scmsync projects, providing the project, its repositories and the name/title/description the action and its view need. Side effect: a request for a package that does not exist on the backend now returns 404 (Package::UnknownObjectError) instead of 500. Non-scmsync projects are unaffected: a normal missing package already raised in check_package_access before this line. Fixes openSUSE#20224
Jarvis-J-Jacob
force-pushed
the
fix/20224-binary-packages-scmsync-nil
branch
from
September 2, 2026 15:00
2e3e710 to
0b729e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
GET /public/binary_packages/:project/:packagereturns HTTP 500(
undefined method 'project' for nil) when the requested package belongsto a project that uses
scmsync— e.g.https://api.opensuse.org/public/binary_packages/openSUSE:Leap:16.0/eza.Why
Packages of
scmsyncprojects live in the project's git repository, notin the database.
#binary_packagesguards access withcheck_package_access(..., use_source: false), which callsPackage.get_by_project_and_name(..., use_source: false). For a packageof an
scmsyncproject that method returnsnilinstead of raising(it only follows the scmsync link when
follow_project_scmsync_links: true), so the guard passes.@pkgis thenniland the action crashesat
@pkg.project.repositories.This adds a fallback: when the DB lookup returns
nil, build a read-onlyPackagefrom the backend package meta(
follow_project_scmsync_links: true), which provides the project, itsrepositories, and the package name/title/description the action renders.
Side effects
returns 404 (
Package::UnknownObjectError) instead of 500.lookup returns
nil, which for a normal missing package already raisedin
check_package_accessbefore this line.deploy time.
How to verify
Automated (new spec
GET #binary_packages for a package of an scmsync project; whole file green, 51 examples):docker compose run --rm frontend bundle exec rspec spec/controllers/public_controller_spec.rb
Manual:
scmsyncURL: edit the project meta and add<scmsync>https://example.com/whatever.git</scmsync>(web UI metaeditor, or
osc meta prj <project>).database:
curl -i http://localhost:3000/public/binary_packages//
masterthis responds500. With this PR it responds200(or404if the package also doesn't exist on the backend).AI use is disclosed via the
Assisted-by:trailer on the commit; thechange was reviewed and tested locally before submitting.
Fixes #20224