{"record":{"id":"6626059c0283907c","repo":"BoundaryML/baml","slug":"no-upload-metadata-provided-when-should-upload-is-true","errorCode":null,"errorMessage":"No upload metadata provided when should_upload is true","messagePattern":"No upload metadata provided when should_upload is true","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/tracingv2/publisher/publisher.rs","lineNumber":646,"sourceCode":"                tracing::warn!(\"Failed to check BAML source upload status: {}\", e);\n                return Err(e.into());\n            }\n        };\n        tracing::debug!(\"check_response={:?}\", check_response);\n\n        if !check_response.should_upload {\n            tracing::debug!(\"BAML source already uploaded, skipping\");\n            return Ok(());\n        }\n\n        tracing::debug!(\"Uploading BAML source\");\n\n        let upload_url = check_response\n            .upload_url\n            .ok_or_else(|| anyhow::anyhow!(\"No upload URL provided when should_upload is true\"))?;\n\n        let upload_metadata = check_response.upload_metadata.ok_or_else(|| {\n            anyhow::anyhow!(\"No upload metadata provided when should_upload is true\")\n        })?;\n\n        // Create the upload payload\n        let payload = BamlSrcUploadS3File { ast: ast_obj };\n\n        // Upload to S3\n        lookup\n            .client\n            .put(upload_url)\n            .json(&payload)\n            .headers({\n                let mut headers = reqwest::header::HeaderMap::new();\n                for (key, value) in upload_metadata.to_map() {\n                    let header_name = format!(\"x-amz-meta-{key}\");\n                    if let (Ok(name), Ok(val)) = (\n                        reqwest::header::HeaderName::from_bytes(header_name.as_bytes()),\n                        reqwest::header::HeaderValue::from_str(&value),\n                    ) {","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/tracingv2/publisher/publisher.rs#L628-L664","documentation":"Raised in process_baml_src_upload_impl (called by process_baml_src_upload) when the server's check response indicates should_upload is true but the upload_metadata field is missing. The publisher needs the pre-signed S3 metadata (fields/headers) alongside the URL to perform the multipart upload; without it the upload cannot be authenticated or formed. Like error 1094, it signals an inconsistent server response.","triggerScenarios":"The collector's upload-check response has should_upload=true but upload_metadata=None — server-side bug, client/server schema drift, or a proxy rewriting the JSON response and dropping the metadata field.","commonSituations":"Mismatched BAML runtime and BAML cloud versions, self-hosted gateway with stale schema, or intermediaries (proxies, WAFs) modifying response payloads.","solutions":["Upgrade the BAML runtime and cloud/gateway to matching versions.","Inspect whether a proxy/WAF is stripping response fields.","Retry publishing; report the raw response to BAML support if persistent.","Disable source upload in trace settings if telemetry upload is not needed."],"exampleFix":"// before\nlet upload_metadata = check_response.upload_metadata.unwrap();\n// after\nlet upload_metadata = check_response.upload_metadata.ok_or_else(|| {\n    anyhow::anyhow!(\"No upload metadata provided when should_upload is true\")\n})?;","handlingStrategy":"try-catch","validationCode":"# validate check response shape before uploading\nresp = requests.post(f\"{BAML_URL}/v1/baml-src/check\", headers=auth, json=req).json()\nif resp.get(\"should_upload\") and not resp.get(\"upload_metadata\"):\n    raise RuntimeError(\"missing upload_metadata in check response\")","typeGuard":"def has_upload_metadata(resp) -> bool:\n    return not resp.should_upload or resp.upload_metadata is not None","tryCatchPattern":"match process_baml_src_upload().await {\n    Err(e) if e.to_string().contains(\"No upload metadata\") => {\n        log::warn!(\"collector omitted upload metadata; skipping src upload\");\n    }\n    Err(e) => return Err(e),\n    Ok(_) => {}\n}","preventionTips":["Keep client and server API schemas in sync (upgrade together)","Log full check response when uploads fail","Verify no intermediary strips JSON fields","Retry once before giving up on transient server glitches"],"tags":["baml","tracing","upload","unexpected-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}