{"record":{"id":"429af77df07deca8","repo":"clockworklabs/SpacetimeDB","slug":"pre-publish-check-failed-with-status","errorCode":null,"errorMessage":"Pre-publish check failed with status {}: {}","messagePattern":"Pre-publish check failed with status (.+?): (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/publish.rs","lineNumber":992,"sourceCode":") -> Result<Option<PrePublishResult>, anyhow::Error> {\n    let mut builder = client.post(format!(\"{database_host}/v1/database/{domain}/pre_publish\"));\n    let style: PrettyPrintStyle = pretty_print_style_from_env();\n    builder = builder\n        .query(&[(\"pretty_print_style\", style)])\n        .query(&[(\"host_type\", host_type)]);\n\n    builder = add_auth_header_opt(builder, auth_header);\n\n    println!(\"Checking for breaking changes...\");\n    let res = builder.body(program_bytes.to_vec()).send().await?;\n\n    if res.status() == StatusCode::NOT_FOUND {\n        // This is a new database, so there are no breaking changes\n        return Ok(None);\n    }\n\n    if !res.status().is_success() {\n        anyhow::bail!(\n            \"Pre-publish check failed with status {}: {}\",\n            res.status(),\n            res.text().await?\n        );\n    }\n\n    let pre_publish_result: PrePublishResult = res.json_or_error().await?;\n    Ok(Some(pre_publish_result))\n}\n\n#[cfg(test)]\nmod tests {\n    use pretty_assertions::assert_matches;\n    use spacetimedb_lib::Identity;\n    use std::collections::HashMap;\n\n    use super::*;\n","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/subcommands/publish.rs#L974-L1010","documentation":"Every publish to an existing database first POSTs the module bytes to the pre-publish (schema-diff) endpoint. A 404 is tolerated (it means new database, no breaking changes); any other non-success status bails here with the HTTP status code and the raw response body embedded in the message.","triggerScenarios":"`spacetime publish` where the pre-publish HTTP call returns 401/403 (expired or invalid token), 400 (malformed identity or request), 5xx (server-side failure), or an error page from a proxy/load balancer sitting in front of the server.","commonSituations":"Token expired or from a different server; CLI newer than a self-hosted standalone server that lacks or changed the pre-publish route (version skew); reverse proxies returning HTML error pages; database left in a bad state after a crashed publish (check server logs).","solutions":["Read the embedded status and body: 401/403 means re-run `spacetime login`; a panic/stack trace means inspect the server logs.","Check connectivity and version pairing: `spacetime server ping`, and update the standalone server (`spacetime start`/server update) or the CLI so they match.","Retry once after a short delay for transient 5xx or network blips.","If a proxy is involved, verify it forwards the request with the full body (the module bytes are sent as the request body)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Pre-flight before publishing\nspacetime server ping \"$SERVER\" || exit 1\nspacetime login >/dev/null 2>&1 || true   # refresh credentials if they may be stale","typeGuard":null,"tryCatchPattern":"for attempt in 1 2 3; do\n  out=$(spacetime publish mydb 2>&1); status=$?\n  [ $status -eq 0 ] && break\n  echo \"$out\" | grep -q \"Pre-publish check failed with status 5\" || { echo \"$out\"; exit 1; }\n  sleep $((attempt * 5))\ndone","preventionTips":["Pin CLI and server versions together in CI (upgrade both in the same change).","Keep the auth token fresh; re-login after switching servers.","Retry only on 5xx statuses; 4xx statuses indicate a request/auth problem that retrying will not fix."],"tags":["publish","http","server-error","pre-publish-check","version-skew"],"backgroundTag":"server-error-response","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}