{"record":{"id":"764c4910f84543ce","repo":"jdx/mise","slug":"starting-blob-upload-failed","errorCode":null,"errorMessage":"starting blob upload failed: {} {}{}","messagePattern":"starting blob upload failed: (.+?) (.+?)(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/oci/registry.rs","lineNumber":1362,"sourceCode":"                let mut rb = HTTP\n                    .reqwest()?\n                    .post(start_url.as_str())\n                    .header(\"Content-Length\", \"0\");\n                if let Some(a) = auth {\n                    rb = rb.header(\"Authorization\", a);\n                }\n                Ok(rb)\n            })\n            .await\n            .wrap_err_with(|| format!(\"POST {start_url}\"))?;\n        let status = resp.status();\n        match status {\n            StatusCode::CREATED => return Ok(UploadOutcome::Mounted),\n            StatusCode::ACCEPTED => {}\n            s => {\n                // Let transient statuses bubble as retryable errors.\n                resp.error_for_status_ref()?;\n                bail!(\n                    \"starting blob upload failed: {} {}{}\",\n                    s.as_u16(),\n                    start_url,\n                    push_auth_hint(s, had_credential),\n                );\n            }\n        }\n        let mut location = self.resolve_location(&resp)?;\n        pr.set_position(0);\n\n        // 2. Transfer the bytes.\n        if size > UPLOAD_CHUNK_SIZE {\n            // Chunked: PATCH each segment, then a zero-length finalizing PUT.\n            let mut offset = 0u64;\n            while offset < size {\n                let len = UPLOAD_CHUNK_SIZE.min(size - offset);\n                let err_slot: UploadErrSlot = Default::default();\n                let resp = self","sourceCodeStart":1344,"sourceCodeEnd":1380,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/oci/registry.rs#L1344-L1380","documentation":"Thrown when the initial POST that starts a blob upload (or cross-repo mount) to an OCI registry returns a status other than 201 (mounted) or 202 (upload session started). The message includes the status code, the start URL, and an auth hint when credentials were involved.","triggerScenarios":"`upload_blob_once` POSTing to the registry's `/v2/<name>/blobs/uploads/` endpoint and receiving e.g. 401/403 (bad credentials), 404 (repository doesn't exist), 405, or 5xx that is not retried away.","commonSituations":"Pushing to a repository that doesn't exist and the registry doesn't auto-create repos (404); expired or wrong push credentials (401/403); pushing to the wrong registry hostname; registry rate limits or outage.","solutions":["Run `docker login <registry>` (or equivalent) to obtain valid push credentials.","Create the repository/namespace in the registry if it requires pre-creation.","Verify the registry URL and that your account has push permission.","Retry if the registry was returning transient 5xx."],"exampleFix":"// before: unauthenticated push\nregistry.push(\"ghcr.io/acme/app:latest\")?;\n// after: ensure login first\n// $ docker login ghcr.io\nregistry.push(\"ghcr.io/acme/app:latest\")?;","handlingStrategy":"try-catch","validationCode":"let ok = reqwest::Client::new()\n    .get(format!(\"https://{host}/v2/\")).send().await\n    .map(|r| r.status().is_success() || r.status() == StatusCode::UNAUTHORIZED).unwrap_or(false); // 401 with WWW-Authenticate is normal\nif !ok { eprintln!(\"registry unreachable/misconfigured: {host}\"); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = push_image(dir) {\n    let msg = e.to_string();\n    if msg.contains(\"401\") || msg.contains(\"403\") { relogin_and_retry(); }\n    else if msg.contains(\"404\") { create_repo_or_fix_name(); }\n    else { return Err(e); }\n}","preventionTips":["Run `docker login <registry>` before automated pushes; confirm token expiry windows.","Verify the account has push scope for the target namespace.","Create the repository beforehand on registries that don't auto-create."],"tags":["network","http","oci","push","auth"],"backgroundTag":"http-error-response","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}