SWH: ‘lookup-origin-revision’ can miss tags

OpenSubmitted by Ludovic Courtès.
Details
2 participants
  • Ludovic Courtès
  • Ludovic Courtès
Owner
unassigned
Severity
important
L
L
Ludovic Courtès wrote on 9 Nov 2021 18:11
(address . bug-guix@gnu.org)
87mtmdi7a3.fsf@gnu.org
Toggle snippet (54 lines)
> However, I get this:
>
> $ guix lint -c archival sway
> gnu/packages/wm.scm:1527:5: sway@1.5.1: scheduled Software Heritage archival

Indeed, I’m getting that as well.

Right now Sway’s origin refers to the “1.5.1” tag.

I found the problem:

scheme@(guile-user)> ,use(guix swh)
scheme@(guile-user)> (lookup-origin-revision "https://github.com/swaywm/sway" "1.5.1")
$2 = #f
scheme@(guile-user)> (lookup-origin "https://github.com/swaywm/sway")
$3 = #<<origin> visits-url: "https://archive.softwareheritage.org/api/1/origin/https://github.com/swaywm/sway/visits/" type: #<unspecified> url: "https://github.com/swaywm/sway">
scheme@(guile-user)> (car (origin-visits $3))
$4 = #<<visit> date: #<date nanosecond: 490956 second: 6 minute: 45 hour: 14 day: 29 month: 10 year: 2021 zone-offset: 0> origin: "https://github.com/swaywm/sway" url: "https://archive.softwareheritage.org/api/1/origin/https://github.com/swaywm/sway/visit/41/" snapshot-url: "https://archive.softwareheritage.org/api/1/snapshot/10ba0257e3290ce4504c2413f32b9358d72975d6/" status: full number: 41>
scheme@(guile-user)> (define s (visit-snapshot $4))
scheme@(guile-user)> ,pp (map branch-name (snapshot-branches s))
*** output flushed ***
scheme@(guile-user)> (length (snapshot-branches s))
$6 = 1000
scheme@(guile-user)> (filter (lambda (b)
(string-prefix? "refs/tags" (branch-name b)))
(snapshot-branches s))
$7 = ()
scheme@(guile-user)> ,use(srfi srfi-1)
scheme@(guile-user)> ,pp (take (snapshot-branches s) 10)
$8 = (#<<branch> name: "refs/pull/2715/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/2f258eff6fd2c89a94caa658c1ea22beb76d728a/">
#<<branch> name: "refs/pull/2713/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/4e4898e90f4d9b721091137a744deac335e73f12/">
#<<branch> name: "refs/pull/2712/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/d129108cddc485299443d0b98c3bdf3f9839aa1c/">
#<<branch> name: "refs/pull/271/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/20cb390323b19dc0c767ba63925def7f51c31044/">
#<<branch> name: "refs/pull/2709/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/426c33f4dc2515867a0d3b04cb865d5cad091d10/">
#<<branch> name: "refs/pull/2708/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/b1a0e95e8e6ecf66542cc62e6109949de59afb5e/">
#<<branch> name: "refs/pull/2704/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/6194a445d3b10e8afc968712faccdd1d127a8beb/">
#<<branch> name: "refs/pull/2703/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/f16529e2588f5e71d6777f4c06dfb58b29308cd0/">
#<<branch> name: "refs/pull/2701/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/baeb28ea6230ef9aa409ee52abe208720120e45c/">
#<<branch> name: "refs/pull/270/head" target-type: revision target-url: "https://archive.softwareheritage.org/api/1/revision/a32cbb52ce81ee38d2928ba873ff7fc182df8393/">)

This snapshot has more than 1,000 branches, mostly ‘refs/pull’ branches.
But by default, the endpoint used by ‘visit-snapshot’ only returns the
first 1,000 branches, and then it’s up to the caller to use the
pagination mechanism.

It’s not implemented though! It turns out the ‘refs/tags’ “branches”
were not among the first thousand branches, so the code incorrectly
thinks that the tag is missing.

The solution is to implement pagination (yuk!), or to use an endpoint to
look up a branch by name instead of using ‘snapshot-branches’ (is there
such an endpoint?).

Ludo’.
L
L
Ludovic Courtès wrote on 18 Nov 2021 15:04
control message for bug #51726
(address . control@debbugs.gnu.org)
87o86hpnk4.fsf@gnu.org
severity 51726 important
quit
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to 51726@debbugs.gnu.org