clockworklabs/SpacetimeDB · error · anyhow::Error

Pre-publish check failed with status {}: {}

Error message

Pre-publish check failed with status {}: {}

What it means

The CLI POSTs the module bytes to the pre-publish (breaking-change detection) endpoint and requires success. A 404 is tolerated and treated as 'new database, nothing to compare'; any other non-2xx status bails here with the HTTP status and the server's response body. This is a server-side or request-level failure, not a schema verdict.

Source

Thrown at crates/cli/src/subcommands/publish.rs:851

) -> Result<Option<PrePublishResult>, anyhow::Error> {
    let mut builder = client.post(format!("{database_host}/v1/database/{domain}/pre_publish"));
    let style: PrettyPrintStyle = pretty_print_style_from_env();
    builder = builder
        .query(&[("pretty_print_style", style)])
        .query(&[("host_type", host_type)]);

    builder = add_auth_header_opt(builder, auth_header);

    println!("Checking for breaking changes...");
    let res = builder.body(program_bytes.to_vec()).send().await?;

    if res.status() == StatusCode::NOT_FOUND {
        // This is a new database, so there are no breaking changes
        return Ok(None);
    }

    if !res.status().is_success() {
        anyhow::bail!(
            "Pre-publish check failed with status {}: {}",
            res.status(),
            res.text().await?
        );
    }

    let pre_publish_result: PrePublishResult = res.json_or_error().await?;
    Ok(Some(pre_publish_result))
}

#[cfg(test)]
mod tests {
    use pretty_assertions::assert_matches;
    use spacetimedb_lib::Identity;
    use std::collections::HashMap;

    use super::*;

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Read the included response body — it usually carries the exact server-side reason
  2. Check server health with `spacetime server ping` and restart/upgrade the server if needed
  3. Run `spacetime login` again to refresh a stale token
  4. Update both sides to matching versions (`spacetime update` for the CLI, matching server release)

Example fix

# before
spacetime publish mydb -s https://old-server   # Pre-publish check failed with status 500: ...
# after
spacetime update
spacetime server ping old-server
spacetime publish mydb -s https://old-server
Defensive patterns

Strategy: retry

Validate before calling

# Pre-flight the server before publishing
spacetime server ping "$SERVER" || exit 1

Try / catch

// Retry once on transient 5xx from the pre-publish check
for attempt in 1 2; do
  out=$(spacetime publish db 2>&1) && break
  echo "$out" | grep -q 'Pre-publish check failed with status 5' || { echo "$out"; exit 1; }
  sleep 5
done

Prevention

When it happens

Trigger: The pre-publish request failing with 401/403 (bad or expired token), 413/400 (module bytes rejected), or 5xx (server crash or version mismatch between an old CLI and a newer server that changed/removed the endpoint semantics).

Common situations: CLI/server version skew after upgrading one but not the other; expired login token on maincloud; proxy or gateway between client and server returning an error page; publishing an oversized or malformed .wasm.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/429af77df07deca8. Report an issue: GitHub.