BoundaryML/baml · error

No upload metadata provided when should_upload is true

Error message

No upload metadata provided when should_upload is true

What it means

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.

Solutions

  1. Upgrade the BAML runtime and cloud/gateway to matching versions.
  2. Inspect whether a proxy/WAF is stripping response fields.
  3. Retry publishing; report the raw response to BAML support if persistent.
  4. Disable source upload in trace settings if telemetry upload is not needed.

Example fix

// before
let upload_metadata = check_response.upload_metadata.unwrap();
// after
let upload_metadata = check_response.upload_metadata.ok_or_else(|| {
    anyhow::anyhow!("No upload metadata provided when should_upload is true")
})?;
Defensive patterns

Strategy: try-catch

Validate before calling

# validate check response shape before uploading
resp = requests.post(f"{BAML_URL}/v1/baml-src/check", headers=auth, json=req).json()
if resp.get("should_upload") and not resp.get("upload_metadata"):
    raise RuntimeError("missing upload_metadata in check response")

Type guard

def has_upload_metadata(resp) -> bool:
    return not resp.should_upload or resp.upload_metadata is not None

Try / catch

match process_baml_src_upload().await {
    Err(e) if e.to_string().contains("No upload metadata") => {
        log::warn!("collector omitted upload metadata; skipping src upload");
    }
    Err(e) => return Err(e),
    Ok(_) => {}
}

Prevention

When it happens

Trigger: 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.

Common situations: Mismatched BAML runtime and BAML cloud versions, self-hosted gateway with stale schema, or intermediaries (proxies, WAFs) modifying response payloads.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/6626059c0283907c. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-runtime/src/tracingv2/publisher/publisher.rs:646

                tracing::warn!("Failed to check BAML source upload status: {}", e);
                return Err(e.into());
            }
        };
        tracing::debug!("check_response={:?}", check_response);

        if !check_response.should_upload {
            tracing::debug!("BAML source already uploaded, skipping");
            return Ok(());
        }

        tracing::debug!("Uploading BAML source");

        let upload_url = check_response
            .upload_url
            .ok_or_else(|| anyhow::anyhow!("No upload URL provided when should_upload is true"))?;

        let upload_metadata = check_response.upload_metadata.ok_or_else(|| {
            anyhow::anyhow!("No upload metadata provided when should_upload is true")
        })?;

        // Create the upload payload
        let payload = BamlSrcUploadS3File { ast: ast_obj };

        // Upload to S3
        lookup
            .client
            .put(upload_url)
            .json(&payload)
            .headers({
                let mut headers = reqwest::header::HeaderMap::new();
                for (key, value) in upload_metadata.to_map() {
                    let header_name = format!("x-amz-meta-{key}");
                    if let (Ok(name), Ok(val)) = (
                        reqwest::header::HeaderName::from_bytes(header_name.as_bytes()),
                        reqwest::header::HeaderValue::from_str(&value),
                    ) {

View on GitHub (pinned to bd85ce9dee)