{"record":{"id":"edcd314a1934cf2c","repo":"clockworklabs/SpacetimeDB","slug":"invalid-publish-response-environment","errorCode":null,"errorMessage":"Invalid publish response","messagePattern":"Invalid publish response","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/publish/environment.rs","lineNumber":147,"sourceCode":"        environment: resolved.values,\n        environment_remove: options.remove.clone(),\n        environment_replace: options.replace,\n        expected_module_version: Some(metadata.module_version),\n    };\n    let response = add_auth_header_opt(client.put(url), &auth)\n        .header(reqwest::header::CONTENT_TYPE, CONTENT_TYPE)\n        .body(request.encode()?)\n        .send()\n        .await?;\n    anyhow::ensure!(\n        response.status().is_success(),\n        \"Environment publish failed with HTTP {}\",\n        response.status()\n    );\n    match response\n        .json::<spacetimedb_client_api_messages::name::PublishResult>()\n        .await\n        .map_err(|_| anyhow::anyhow!(\"Invalid publish response\"))?\n    {\n        spacetimedb_client_api_messages::name::PublishResult::Success { database_identity, .. } => {\n            println!(\"Updated environment for database {database_identity}\");\n            Ok(())\n        }\n        spacetimedb_client_api_messages::name::PublishResult::PermissionDenied { .. } => {\n            anyhow::bail!(\"Permission denied publishing environment values\")\n        }\n    }\n}\n","sourceCodeStart":129,"sourceCodeEnd":158,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/subcommands/publish/environment.rs#L129-L158","documentation":"After a successful environment PUT, the CLI parses the response body as `name::PublishResult`. If the body is absent or not valid JSON in the expected shape, the `json()` call fails and this error is thrown. Like error 43, this means a 2xx response did not carry the expected structured result.","triggerScenarios":"Server returns 2xx with empty body or non-JSON content; intermediary proxy rewrites the response; server version returns a PublishResult shape the CLI cannot deserialize.","commonSituations":"Version skew between CLI and server; publishing through a gateway that strips or transforms response bodies; misconfigured server returning empty 200s.","solutions":["Confirm the `--server` URL targets the SpacetimeDB API host directly, not a proxy or dashboard.","Align CLI and server versions (`spacetime --version`) and upgrade whichever is stale.","Curl the same PUT endpoint to inspect the raw body the server returns.","Retry to rule out a truncated response; bypass proxies/CDNs if present."],"exampleFix":"// before\nspacetime publish -s https://gateway.example mydb  # 200 empty body -> Invalid publish response\n// after\nspacetime publish -s https://spacetimedb.example mydb","handlingStrategy":"retry","validationCode":"// confirm server returns JSON content-type on publish endpoints\ncurl -sI \"$SERVER/v1/database\" | grep -qi 'content-type: .*json' || echo \"server not returning JSON\"","typeGuard":null,"tryCatchPattern":"// retry with backoff on unparseable success responses\nmatch publish_env().await {\n    Err(e) if e.to_string().contains(\"Invalid publish response\") => {\n        tokio::time::sleep(Duration::from_secs(2)).await;\n        publish_env().await\n    }\n    other => other,\n}","preventionTips":["Avoid intermediaries (gateways, CDNs) that can alter response bodies.","Keep CLI and server on compatible versions.","Investigate any 2xx-with-empty-body behavior in your server setup before automating publishes."],"tags":["json","environment","publish","response-parsing"],"backgroundTag":"unexpected-response-shape","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-09-20T12:15:59.611Z","contentChangedAt":"2026-09-20T12:15:59.611Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}