Fix install_libstdcc(): replace invalid getDownloadUrl op, add curl -f, improve error diagnostics#1017
Draft
Copilot wants to merge 3 commits intoppa-workaroundfrom
Draft
Fix install_libstdcc(): replace invalid getDownloadUrl op, add curl -f, improve error diagnostics#1017Copilot wants to merge 3 commits intoppa-workaroundfrom
Copilot wants to merge 3 commits intoppa-workaroundfrom
Conversation
Signed-off-by: Ryan Northey <ryan@synca.io>
…add -f to curl, improve error logging Agent-Logs-Url: https://github.com/phlax/toolshed/sessions/1f3fff6e-b4b0-4946-a40d-d30d372f4e18 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix install_libstdcc() CI errors caused by download URL issues
Fix install_libstdcc(): replace invalid getDownloadUrl op, add curl -f, improve error diagnostics
May 5, 2026
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.
install_libstdcc()was failing in CI withjq: parse error: Invalid numeric literaldue to two bugs:getDownloadUrlis not a public op onBinaryPackagePublishingHistory(returning an error body instead of a URL), and missing-foncurlcaused HTTP 5xx responses to be silently written to files, foolingretryinto thinking the call succeeded.Changes
Bug 1 — replace
getDownloadUrlwith+files/<filename>redirect:Use
curl -fsSIL -w '%{url_effective}'against the archive's+files/<pkg>_<ver>_<arch>.debendpoint, which performs a 303 →launchpadlibrarian.net. Sanity-check the resolved URL starts withhttps://launchpadlibrarian.net/before proceeding.Bug 2 — add
-f(+-S) to everycurlin the function:API GETs (
-fsSG) and the.debdownload (-fsSL) now fail on HTTP errors, soretryactually retries instead of forwarding error HTML to jq.Error diagnostics:
JSON parsing is guarded with
if ! jq ...; on failure (e.g. HTML error page), dumps the first 2048 bytes to stderr before exiting. On success, logstotal_sizeanddisplay_namefrom the API response so zero-entry regressions are immediately visible in CI logs.Extract
ppa_web_urlas a local variable alongside the existingppa_urlto avoid the hardcoded web URL inside the loop.Original prompt
Context
The current
install_libstdcc()on branchppa-workaround(filebazel/sysroot/build_sysroot.sh) fails in CI with:There are two distinct bugs causing this. Fix both.
Bug 1:
getDownloadUrlis not a public op onBinaryPackagePublishingHistoryThe current code does:
getDownloadUrlexists onLibraryFileAliasobjects, not onBinaryPackagePublishingHistory. The call returns an error response (JSON error object, sometimes an HTML page on infra failures),jq -r '.'then prints something that isn't a URL, and the subsequentcurleither fails or succeeds writing nonsense to the .deb path. The "Invalid numeric literal" error fires when jq later tries to parse it.The correct, documented way to get the librarian URL for a published binary is the
+files/<filename>HTTP redirect. The Launchpad webservice serves a 303 to thelaunchpadlibrarian.netURL.Replace the
getDownloadUrlblock with:Notes:
-Idoes HEAD (no body, just follow the redirect chain).-Lfollows the redirect.%{url_effective}prints the final URL after redirects — this is thelaunchpadlibrarian.netURL we want.-fmakes curl fail on HTTP error (soretryactually retries).-ssilences progress.-Sshows errors on stderr.retrywraps it cleanly.Then sanity-check the result starts with
https://launchpadlibrarian.net/:Bug 2:
curl -swithout-fsilently writes error bodies to the output fileThe current code uses:
Without
-f, an HTTP 5xx response fromapi.launchpad.netmakes curl exit 0 and dump the error body (often HTML, sometimes plain text) into$meta_file.retrysees exit 0, does NOT retry, and jq then parse-errors on the HTML.Fix every
curlinvocation ininstall_libstdcc()to add-f(and-Sso genuine errors surface). For the API GET calls:For the .deb download:
Add a debug log so future failures are diagnosable in one CI run
Right after the API response is captured, print the first ~300 bytes if the parse looks suspicious. The cleanest way: always log
total_sizeand the first entry's display_name, and dump the whole file on parse failure:This means if the API ever returns 0 entries again (e.g. the
binary_namequoting regression), the CI log will show exactly what we got, instead of an opaque "Invalid numeric literal".Don't pipeline inside
retry(general hygiene)The existing
retryhelper runs"$@"— so a shell pipeline inside an argument list won't work the way you'd expect, andset -e -o pipefailplus partial pipeline output is what produced the interleaved log mess. The fix above already avoids this (everyretrycall wraps a single curl with-o file), so just keep it that way: never put| jq ...directly afterretry curl …. Alwayscurl -o filethenjq … fileas separate steps.Acceptance criteria
install_libstdcc()no longer uses the non-existentgetDownloadUrlop.+files/<filename>HEAD-redirect (-fsSIL -w '%{url_effective}').https://launchpadlibrarian.net/.install_libstdcc()use-f(and-S) so HTTP errors fail the retry attempt.This pull request was created from Copilot chat.