Skip to content

installer: on a 403 from the GitHub API, name quota or access instead of one sentence, and retry anonymously #1889

Closed

Description

@santoshkumarradha

What happened

The installer collapses every GitHub API refusal into one sentence, so a spent
quota is indistinguishable from a repository the token cannot read, and the
response that says which is thrown away:

✗ codeaf: GitHub's API could not be reached or refused (a rate limit, or a repository you cannot read?); pin VERSION=<tag>, or export GITHUB_TOKEN

base: dev@470ab4a6f (the served /get/devaf is scripts/install.sh on its dev
revision, which differs from codeaf/stable and carries INSTALL_NAME=devaf).

Two defects, one failure path:

  1. api_problem renders one sentence for 401, 403-quota, 403-forbidden, 5xx and
    transport failure, while http_get discards the body and the headers of that
    same response. GitHub states the reason on that response
    (x-ratelimit-remaining: 0, x-ratelimit-reset: <epoch>, body
    API rate limit exceeded), and the message therefore cannot name the reason
    or the moment the refusal lifts. Its advice, or export GITHUB_TOKEN, is
    backwards when a token was already exported and is the cause.
  2. A 403 from a token-bearing request aborts even though the anonymous quota is
    a separate bucket. No single unauthenticated retry of the same
    release_api_get is attempted, so an install that could complete fails.

Not a defect, and not to be changed here: the script's header states the
one-repository, API-only intent (REPOSITORY, "no other repository is asked"),
so a fallback to releases.atom or HTML is a deliberate design choice, not an
omission.

Replication

Deterministic (no model).

Drive the repository's own fake GitHub at CODEAF_GITHUB_API (as
internal/release/install_test.go already does, CODEAF_GITHUB_API= +
github.server.URL). The stub answers every /repos/Agent-Field/codeaf/* call
with 403 and:

  • body {"message":"API rate limit exceeded for user ID <id>."}
  • x-ratelimit-limit: 5000, x-ratelimit-remaining: 0, x-ratelimit-reset: <epoch one minute ahead>
  • x-oauth-scopes: repo, workflow so the token itself reads as valid

Run the installer with GITHUB_TOKEN=<any non-empty> and no VERSION. Today it
prints the sentence above and exits 1; the output names neither quota nor the
reset moment, and a valid token is reported as unusable only insofar as the
advice contradicts it. Control: release_api_get without authenticate against
the same stub is still refused by the stub, which is how the missing anonymous
retry is observed.

Field (real models).

None. No model is involved; the behaviour is deterministic.

Where

scripts/install.sh:

  • api_problem — search GitHub's API could not be reached or refused.
  • its call sites — search api_problem (channel selection for --stable, and
    release discovery for the other channels).
  • http_get / release_api_get — search HTTP_STATUS; the status is kept and
    the headers and body are discarded (--output to a file no caller reads).
  • tag_matches_channel and the VERSION pin sit on the same path; the pin is
    the reason the escape hatch is printed.

Acceptance

  • e2e: with the stub above and a token whose account quota is spent, the
    installer finishes the install — exit 0, INSTALL_DIR/INSTALL_NAME present
    and reporting the tag it installed — by retrying the same API call
    unauthenticated, instead of failing with the generic refusal. Driven through
    CODEAF_GITHUB_API; the stub asserts the retried request carried no
    Authorization header.
  • e2e: with a token GitHub rejects (401, body Bad credentials), stderr
    names the token as rejected and does not advise exporting one; exit 1. With
    a 403 that carries no rate-limit headers, stderr names access, not quota.
  • e2e: for the quota 403, stderr states the reason (quota) and the reset
    moment read from x-ratelimit-reset, rendered in the host's local time.
  • Unit: the reason string is a pure function of (status, headers, body):
    remaining: 0 or an API rate limit exceeded body → quota; 401 → rejected
    token; any other 403 → access; and the reset rendering falls back to a
    relative wait when the header is absent.
  • The manual page covering install failures quotes the new wording, and the
    change entry's invalidates names the belief that one sentence covered all
    API refusals.

Activity

  1. added
    bug
    sev:serious
    area:build
    ready for a lane
    on Oct 22, 2026
  2. added a commit that references this issue on Oct 22, 2026
    371d7f1
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

    area:buildbugready for a lanesev:serious

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions