{"record":{"id":"ec980105b2252fb1","repo":"dbt-labs/dbt-core","slug":"upload-filename-failed-status-body","errorCode":null,"errorMessage":"upload {filename} failed: {status}\n{body}","messagePattern":"upload (.+?) failed: (.+?)\n(.+?)","errorType":"http","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"crates/dbt-ci/src/publish.rs","lineNumber":435,"sourceCode":"                    return Ok(());\n                }\n                if status.is_server_error() && attempt < max_attempts {\n                    let delay = backoff(attempt);\n                    eprintln!(\n                        \"warning: upload attempt {attempt}/{max_attempts} for {filename} got {status}; retrying in {}ms\",\n                        delay.as_millis(),\n                    );\n                    tokio::time::sleep(delay).await;\n                    continue;\n                }\n                let body = resp.text().await.unwrap_or_default();\n                if is_already_exists(status, &body) {\n                    eprintln!(\n                        \"• {filename} already published at {url}; treating as success ({status})\"\n                    );\n                    return Ok(());\n                }\n                bail!(\"upload {filename} failed: {status}\\n{body}\");\n            }\n            Err(e) if is_transient(&e) && attempt < max_attempts => {\n                let delay = backoff(attempt);\n                eprintln!(\n                    \"warning: upload attempt {attempt}/{max_attempts} for {filename} failed: {e}; retrying in {}ms\",\n                    delay.as_millis(),\n                );\n                tokio::time::sleep(delay).await;\n                continue;\n            }\n            Err(e) => {\n                return Err(anyhow::Error::new(e).context(format!(\"POST {url}\")));\n            }\n        }\n    }\n}\n\nfn build_upload_form(","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-ci/src/publish.rs#L417-L453","documentation":"This error is raised by upload_dist in crates/dbt-ci/src/publish.rs when an artifact upload (to CodeArtifact or PyPI) fails with a non-success HTTP status that is not recognized as an 'already exists' condition, after all retry attempts for transient failures are exhausted. The bail includes the HTTP status and the response body so the developer can see the registry's actual rejection reason.","triggerScenarios":"Calling upload_codeartifact or upload_pypi with a file whose upload request returns a 4xx/5xx status (e.g. 401 unauthorized, 403 forbidden, 400 bad request) that is not matched by is_already_exists, and where the error is not transient or retries are exhausted.","commonSituations":"Expired or missing registry credentials, uploading a package version that is rejected (immutable version, name mismatch), network/proxy failures that are non-transient, or the registry rejecting a malformed artifact (e.g. wrong filename or broken twine metadata).","solutions":["Inspect the status and body in the message: 401/403 means refresh registry credentials (e.g. aws codeartifact login or pip keyring auth) before retrying.","If the version already exists but wasn't detected as such, bump the version or fix is_already_exists patterns to match your registry's duplicate message.","Retest connectivity/proxy settings if the status is 5xx or a gateway error.","Verify the artifact itself (correct filename, complete wheel/sdist) matches what the registry expects for the project name and version."],"exampleFix":"// before\nupload_dist(...).unwrap();\n// after\nif let Err(e) = upload_dist(...) {\n    eprintln!(\"publish failed (check registry auth/version): {e:#}\");\n    std::process::exit(1);\n}","handlingStrategy":"try-catch","validationCode":"// Rust: check auth + duplicate status before a long publish run\nfn preflight_publish(registry: &str, version: &str) -> anyhow::Result<()> {\n    anyhow::ensure!(!version.is_empty(), \"version required\");\n    // verify credentials early, e.g. `aws codeartifact get-authorization-token` or `twine check`\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match upload_dist(...) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"upload\") => {\n        eprintln!(\"registry rejected upload, check auth/status: {e:#}\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Refresh registry credentials (codeartifact login / keyring) before release jobs.","Bump the version for every publish; never republish an existing version.","Ensure uploads happen after all build steps so artifacts are complete.","Monitor the printed status/body to distinguish auth vs. duplicate vs. transient problems."],"tags":["publishing","http","network","pypi"],"backgroundTag":"http-error-response","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}