App.get_project_refs(): Fix multi-section results #117

Merged
Jan Lindemann merged 1 commit from jan/fix/20260922-app-get-project-refs-fix-multi-section-results into master 2026-09-22 05:07:54 +02:00 AGit

App.get_project_refs(): Fix multi-section results

get_project_refs() takes a list of sections to look for references in. To now, that has never been exercised, i.e. only one section had ever been passed in. With the introduction of pkg.recommends, that could change now, and it has a subtle bug.

Say, a caller wants to retrieve all requires and recommends of package A with this graph:

A recommends B, requires nothing B requires C

then A, B, C should be returned, but the current implementation only returns A and B. The cause is that every section is recursed into in isolation, and the union of all results is returned. Since A doesn't require anything, the requires-branch never reaches B, and C is missed.

The fix is to make __get_project_refs(), the recursing method, take a list of sections instead of one section, and decide if it recurses deeper based on all of its entries at every depth.

#### App.get_project_refs(): Fix multi-section results get_project_refs() takes a list of sections to look for references in. To now, that has never been exercised, i.e. only one section had ever been passed in. With the introduction of pkg.recommends, that could change now, and it has a subtle bug. Say, a caller wants to retrieve all requires and recommends of package A with this graph: A recommends B, requires nothing B requires C then A, B, C should be returned, but the current implementation only returns A and B. The cause is that every section is recursed into in isolation, and the union of all results is returned. Since A doesn't require anything, the requires-branch never reaches B, and C is missed. The fix is to make __get_project_refs(), the recursing method, take a list of sections instead of one section, and decide if it recurses deeper based on all of its entries at every depth.
App.get_project_refs(): Fix multi-section results
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 6m2s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m41s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m3s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m45s
CI / Packaging test (push) Successful in 0s
63bc5efdc3
get_project_refs() takes a list of sections to look for references in. To
now, that has never been exercised, i.e. only one section had ever been
passed in. With the introduction of pkg.recommends, that could change now,
and it has a subtle bug.

Say, a caller wants to retrieve all requires and recommends of package A
with this graph:

  A recommends B, requires nothing
  B requires C

then A, B, C should be returned, but the current implementation only
returns A and B. The cause is that every section is recursed into in
isolation, and the union of all results is returned. Since A doesn't
require anything, the requires-branch never reaches B, and C is missed.

The fix is to make __get_project_refs(), the recursing method, take a list
of sections instead of one section, and decide if it recurses deeper based
on all of its entries at every depth.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.86.1
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-09-22 04:57:07 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!117
No description provided.