Jguer/yay · error
invalid status code
Error message
invalid status code: %d
What it means
GetPackageScanner fetches a package list (AUR packages.gz / packages-metadata) over HTTP and requires HTTP 200. Any other status (404, 403, 5xx) closes the body and returns 'invalid status code: <code>'. Callers like syncList and createAURList then fail to build the AUR package list.
Solutions
- Retry later or check https://status.archlinux.org — 5xx/429 usually means AUR is down or rate-limiting
- Verify the aururl config (yay -Pg) points to https://aur.archlinux.org and correct it if overridden
- Test connectivity manually: curl -I https://aur.archlinux.org/packages.gz to see the actual status
- If behind a proxy, set/clear HTTP(S)_PROXY env vars and ensure they allow the AUR domain
Example fix
// before
resp, _ := http.Get(aurURL + "/packages.gz") // blindly fails: invalid status code: 503
// after
resp, _ := http.Get(aurURL + "/packages.gz")
if resp != nil && resp.StatusCode == http.StatusTooManyRequests {
time.Sleep(retryAfterDelay(resp)) // honor backoff, then retry once
resp, _ = http.Get(aurURL + "/packages.gz")
}
// and check configured URL: curl -I $aurUrl/packages.gz before blaming the client Defensive patterns
Strategy: retry
Validate before calling
u := cfg.AurURL + "/packages.gz"
if pu, err := url.Parse(u); err != nil || pu.Scheme != "https" || pu.Host == "" {
return fmt.Errorf("invalid aurUrl %q", u)
}
// preflight: resp, err := http.Head(u); ok := err == nil && resp.StatusCode == 200 Try / catch
var body []byte
for attempt := 0; attempt < 3; attempt++ {
body, err = fetchPackagesGz(ctx)
if err == nil { break }
var sce interface{ StatusCode() int }
if errors.As(err, &anyResp{}) || strings.Contains(err.Error(), "invalid status code") {
time.Sleep(time.Duration(1<<attempt) * time.Second) // backoff for 429/5xx
continue
}
return err
} Prevention
- Check https://status.archlinux.org before blaming your code on AUR 5xx
- Don't override aururl unless you mirror the AUR; verify with curl -I
- Honor 429/Retry-After; poll at reasonable intervals (the AUR rate-limits)
- Set correct proxy env vars in CI/container environments
When it happens
Trigger: The HTTP GET of the AUR metadata endpoint returns a non-200 status: AUR server outage/503, wrong aurUrl in config, rate limiting (429), captive proxy returning 403, or DNS/routing to a stale mirror returning 404.
Common situations: AUR maintenance windows or heavy load (5xx); custom aururl pointing at an old domain; corporate proxy blocking the request; typos in aururl config.
Related errors
- package not found in repos
- failed to retrieve aur Cache
- problem importing keys
- failed to parse
- error resetting
AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/52315c25b2c4ee52.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/download/aur.go:138
// GetPackageScanner fetches the AUR packages.gz file and returns a scanner for reading its contents.
// The caller must call Close() on the returned ScannerCloser when done to properly release resources.
func GetPackageScanner(ctx context.Context, client HTTPRequestDoer, aurURL string, logger *text.Logger) (*ScannerCloser, error) {
u, err := url.Parse(aurURL)
if err != nil {
return nil, err
}
u.Path = path.Join(u.Path, "packages.gz")
packagesURL := u.String()
resp, err := client.Get(packagesURL)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
resp.Body.Close()
return nil, fmt.Errorf("invalid status code: %d", resp.StatusCode)
}
// Read the entire body to allow trying gzip decompression
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
}
// Try to decompress as gzip; if that fails, use raw body
var reader io.Reader
var closer io.Closer
gzReader, gzErr := gzip.NewReader(bytes.NewReader(body))
if gzErr == nil {
reader = gzReader
closer = gzReaderView on GitHub (pinned to 328f4b4939)