nikivdev/code · error

registry upload failed for

Error message

registry upload failed for {} ({})

What it means

During publish, each binary is PUT/POSTed to the registry with an Authorization bearer token and X-Sha256 header. If the registry responds with a non-2xx status, publish bails with 'registry upload failed for <bin> (<status>)'.

Solutions

  1. Check the HTTP status printed in the error and the registry server logs for the exact rejection reason.
  2. Refresh or correct your bearer token (login again / update registry credentials).
  3. If 409 conflict, bump the version or use an appropriate overwrite flag.
  4. Retry later if the status is 5xx (registry-side problem).

Example fix

null
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: verify credentials and that the version is new
let status = client.get(format!("{registry}/packages/{pkg}/{ver}/manifest.json")).send()?.status();
if status == reqwest::StatusCode::CONFLICT {
    return Err("version already published; bump version first".into());
}

Try / catch

match publish(opts) {
    Err(e) if e.to_string().contains("registry upload failed") => {
        if is_server_error(&e) {
            retry_with_backoff(3, || publish(opts.clone()));
        } else {
            eprintln!("Upload rejected: check token/permissions/version conflict");
            std::process::exit(1);
        }
    }
    other => other,
}

Prevention

When it happens

Trigger: Uploading binary `bin` to `<registry_url>/packages/...` and receiving a non-success HTTP status, e.g. 401 (bad/expired token), 403 (no permission), 409 (version exists), or 5xx (registry outage).

Common situations: Expired or wrong registry token; publishing a version that already exists; registry rejecting too-large binaries; registry maintenance/downtime.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/0ac494959bf5be02. Report an issue: GitHub.

Appendix: source

Thrown at src/registry.rs:191

        .unwrap_or(DEFAULT_TOKEN_ENV);
    let token = resolve_registry_token(token_env)?;
    let client = Client::builder().timeout(Duration::from_secs(60)).build()?;

    for bin in &bins {
        let path = project_root.join("target").join("release").join(bin);
        let key = format!("packages/{}/{}/{}/{}", package, version, target, bin);
        let url = format!("{}/{}", registry_url, key);
        let body = fs::read(&path)?;
        let sha = sha256_file(&path)?;
        let response = client
            .put(url)
            .header("Authorization", format!("Bearer {}", token))
            .header("X-Sha256", sha)
            .body(body)
            .send()
            .context("failed to upload binary")?;
        if !response.status().is_success() {
            bail!("registry upload failed for {} ({})", bin, response.status());
        }
    }

    let manifest_url = format!(
        "{}/packages/{}/{}/manifest.json",
        registry_url, package, version
    );
    let mut request = client
        .put(manifest_url)
        .header("Authorization", format!("Bearer {}", token))
        .body(serde_json::to_string_pretty(&manifest)?);
    if latest {
        request = request.query(&[("latest", "1")]);
    }
    let response = request.send().context("failed to upload manifest")?;
    if !response.status().is_success() {
        bail!("registry manifest upload failed ({})", response.status());
    }

View on GitHub (pinned to a747e741ae)