Skip to content

with build :seed and :deps can never find a release asset — the GitHub API response is parsed line-by-line but returns compact JSON #1079

Closed

Description

@migueldecimal128

Summary

with build :seed and with build :deps can never find a release asset. Both
fail with

error: seed: could not find a release containing asset 'with-darwin-aarch64'
error: deps: could not find a release containing asset 'with-llvm-sdk-22.1.6-darwin-aarch64.tar.gz'

even though both assets are published on the latest release. The lookup is not
flaky and it is not a network problem: seed_release_from_api parses the GitHub
API response line by line, and the GitHub REST API returns compact JSON
— the entire response is a single line. The scan therefore runs exactly one
iteration and can never pair a release tag with an asset name.

This is a recovery-path failure, which is what makes it worth fixing promptly:
the command that repairs a stale seed is the command that is broken. A checkout
whose installed compiler has fallen behind main cannot bootstrap itself back
without knowing the undocumented env-var workaround.

Root cause

build/seed.w:138 seed_release_from_api:

let fetch_rc = seed_fetch_to_file(ctx, tmp_dir, "release-api",
    "https://api.github.com/repos/" ++ repo ++ "/releases?per_page=10", body_path, 120000)
...
let lines = seed_split_nonempty_lines(body)          // :149
var current_tag = ""
for li in 0..lines.len() as i32:
    let line = lines.get(li as i64)
    let tag = seed_json_line_value(line, "tag_name")
    if tag.len() > 0:
        current_tag = tag
    let name = seed_json_line_value(line, "name")
    if current_tag.len() > 0 and name == asset_name:
        return current_tag
""

The loop is a state machine over pretty-printed JSON: walk one key per line,
remember the most recent tag_name, and return it when an asset's name line
matches. seed_json_line_value (:49) returns the first occurrence of a key
within the line it is given.

GitHub returns the response with no newlines. So:

  • seed_split_nonempty_lines produces 1 line of 239,931 bytes
  • seed_json_line_value(line, "tag_name") returns the first tag_name in the
    whole document — v0.15.1.12 (correct, by luck)
  • seed_json_line_value(line, "name") returns the first "name" in the whole
    document, which is the release's own display name, With v0.15.1.12,
    because it precedes assets[] in GitHub's field order
  • "With v0.15.1.12" != "with-darwin-aarch64" → loop ends → ""

One iteration, one comparison, no match. The assets are never reached.

Reproduction

$ with build :seed
error: seed: could not find a release containing asset 'with-darwin-aarch64'

$ gh release view --json tagName,assets -q '.tagName, (.assets[].name)'
v0.15.1.12
with-darwin-aarch64                                  <- it is right there
with-darwin-aarch64.sha256
with-llvm-sdk-22.1.6-darwin-aarch64.tar.gz
...

Evidence

Fetching the endpoint with the build's own helper — the same binary
seed_fetch_to_file compiles and runs, so this is the exact byte stream the
parser sees:

$ ./out/tmp/seed-download/https_fetch \
    "https://api.github.com/repos/withlang-dev/with/releases?per_page=10" releases.json
$ wc -l releases.json
       0 releases.json          <- zero newlines, 239931 bytes

Running seed_split_nonempty_lines and seed_json_line_value transcribed
verbatim from build/seed.w against that body:

body bytes     = 239931
lines produced = 1
  line 0: tag_name -> 'v0.15.1.12'   name -> 'With v0.15.1.12'
RESULT = ''  (empty => 'could not find a release containing asset')

Expected vs actual

Expected seed_release_from_api returns v0.15.1.12, the newest release carrying the asset
Actual returns ""; the caller reports the asset does not exist on any release

Impact

Both call sites are affected, since they share the helper:

  • build/seed.w:227 — run_seed_download_action (with build :seed)
  • build/seed.w:276 — the SDK download (with build :deps)

Observed consequence: an environment whose installed compiler has fallen behind
main cannot recover through the documented path. with build then fails with
an error that points at the compiler rather than at the seed — on main at
5a21c2e0 a v0.15.1.7 seed dies with comptime index requires an array, tuple, or vec, and on a branch based on af7db8ce the same stale seed dies with
expression kind 26 is not comptime-evaluable yet during pcre2-wo-build. Two
unrelated-looking errors, one cause, and the repair command is the broken one.

Workaround

Skip the lookup by pinning the tag explicitly:

SEED_VERSION=v0.15.1.12 with build :seed
WITH_LLVM_SDK_VERSION=v0.15.1.12 with build :deps

Both are already read at build/seed.w:223 and :272 respectively.

Suggested fix

Parse the document rather than its lines. Two options:

  1. Preferred — use std.json and walk releases[].assets[].name, returning
    the enclosing releases[].tag_name. Correct by construction, and immune to
    an asset name appearing in a release's markdown body. Worth confirming
    JsonDocument.parse is reachable from a build action under comptime
    evaluation before committing to this.
  2. Minimal — keep the byte scan but run it over the whole body instead of
    per line: walk occurrences of "tag_name" and "name" in document order,
    tracking the most recent tag. This matches the loop's original intent and is
    a small diff, but it can still be fooled by a release body containing
    "name":.

Either way the failure should also be distinguishable from "the asset genuinely
is not published" — the current message asserts something the code never
actually checked.

Notes

  • Both seed_split_nonempty_lines and seed_json_line_value are otherwise
    fine; the defect is purely the assumption that the response has one key per
    line.
  • This was raised once before, in a comment on comptime integer arithmetic evaluates at 32 bits — 3000000001i64 + 0i64 silently yields -1294967295 #943, and then withdrawn as
    unsubstantiated ("Replaying that function's algorithm against the live
    releases?per_page=10 response finds the asset and returns a tag"). That
    withdrawal was mistaken — a replay only succeeds against a pretty-printed copy
    of the response, such as what gh api or a browser renders. Against the raw
    bytes the helper writes, it returns "" deterministically, as shown above.
    The original attribution to seed_release_from_api was correct.

Activity

  1. joshhickson commented on Sep 28, 2026

    @joshhickson
    Contributor

    Still reproduces on main 355c20b1 (after #1805) on Linux x86_64 (WSL2): with build :deps →
    error: deps: could not find a release containing asset 'with-llvm-sdk-22.1.6-linux-x86_64.tar.gz', although the asset
    is on nightly-20260926-local-1-2e8defaa18ef. Worked around by downloading it by hand; its SHA-256 matches the
    release's sidecar.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    Contributor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce in source. seed_release_from_api (build/seed.w:142) no longer scans lines: it splits each page on "tag_name" and looks for the quoted asset name in each release (6572eab, #2008, after the 2026-09-26 comment). The 2026-10-25 seed cut fetched and pinned nightly-20261025-local-1-c88f3eeff0bc through :seed on all four gating hosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions