{"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":851,"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":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/publish.rs#L833-L869","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the included response body — it usually carries the exact server-side reason","Check server health with `spacetime server ping` and restart/upgrade the server if needed","Run `spacetime login` again to refresh a stale token","Update both sides to matching versions (`spacetime update` for the CLI, matching server release)"],"exampleFix":"# before\nspacetime publish mydb -s https://old-server   # Pre-publish check failed with status 500: ...\n# after\nspacetime update\nspacetime server ping old-server\nspacetime publish mydb -s https://old-server","handlingStrategy":"retry","validationCode":"# Pre-flight the server before publishing\nspacetime server ping \"$SERVER\" || exit 1","typeGuard":null,"tryCatchPattern":"// Retry once on transient 5xx from the pre-publish check\nfor attempt in 1 2; do\n  out=$(spacetime publish db 2>&1) && break\n  echo \"$out\" | grep -q 'Pre-publish check failed with status 5' || { echo \"$out\"; exit 1; }\n  sleep 5\ndone","preventionTips":["Keep CLI and server versions matched; upgrade both together","Refresh tokens with `spacetime login` on a schedule in long-lived automation","Always read the response body included in the message — it names the server-side cause"],"tags":["spacetimedb","publish","http-error","pre-publish","server-error"],"backgroundTag":"http-error-response","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}