{"record":{"id":"2acd1ae14de91e86","repo":"clockworklabs/SpacetimeDB","slug":"you-need-to-be-logged-in-as-the-owner-of-name-to","errorCode":null,"errorMessage":"You need to be logged in as the owner of {name} to publish to {name}","messagePattern":"You need to be logged in as the owner of (.+?) to publish to (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/publish.rs","lineNumber":804,"sourceCode":"                let op = match op {\n                    PublishOp::Created => \"Created new\",\n                    PublishOp::Updated => \"Updated\",\n                };\n                if let Some(ref domain) = domain {\n                    println!(\"{op} database with name: {domain}, identity: {database_identity}\");\n                } else {\n                    println!(\"{op} database with identity: {database_identity}\");\n                }\n\n                if is_maincloud_host(&database_host)\n                    && let Some(domain) = domain.as_ref()\n                {\n                    println!(\"Dashboard: https://spacetimedb.com/{}\", domain.as_ref());\n                }\n            }\n            PublishResult::PermissionDenied { name } => {\n                if anon_identity {\n                    anyhow::bail!(\"You need to be logged in as the owner of {name} to publish to {name}\",);\n                }\n                // If we're not in the `anon_identity` case, then we have already forced the user to log in above (using `get_auth_header`), so this should be safe to unwrap.\n                let token = config.spacetimedb_token().unwrap();\n                let identity = decode_identity(token)?;\n                //TODO(jdetter): Have a nice name generator here, instead of using some abstract characters\n                // we should perhaps generate fun names like 'green-fire-dragon' instead\n                let suggested_tld: String = identity.chars().take(12).collect();\n                return Err(anyhow::anyhow!(\n                    \"The database {name} is not registered to the identity you provided.\\n\\\n                    We suggest you push to either a domain owned by you, or a new domain like:\\n\\\n                    \\tspacetime publish {suggested_tld}\\n\",\n                ));\n            }\n        }\n    }\n\n    Ok(())\n}","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/subcommands/publish.rs#L786-L822","documentation":"The server answered the publish request with PublishResult::PermissionDenied: the target database name is registered to a different identity. The CLI then checks whether it is acting anonymously (--anonymous flag or no saved login token); in that case it bails with this message instead of the 'not registered to the identity you provided' error shown to logged-in users. The intent is to distinguish 'you have no identity at all' from 'wrong identity'.","triggerScenarios":"`spacetime publish <name>` where <name> already exists on that server and is owned by another identity, combined with anon_identity=true (--anonymous passed, or the command config sets anonymous, or no spacetimedb token is saved and login was skipped via --yes=skip-login).","commonSituations":"Fresh machine/container/CI with no `spacetime login` credentials; name collision with someone else's database on maincloud; publishing to the wrong server where your account does not own the name; scripts carrying a stray --anonymous flag.","solutions":["Run `spacetime login` on this machine/server and retry the publish.","Verify you are on the intended server: `spacetime server list`, and re-run with `--server <name>` if needed.","If you do not own the name, publish under a name/domain you own (the logged-in branch of this same code even suggests a domain prefix derived from your identity).","Remove `--anonymous` from scripts, aliases, and command config."],"exampleFix":"# before\nspacetime publish mydb --anonymous\n# after\nspacetime login\nspacetime publish mydb","handlingStrategy":"validation","validationCode":"# Ensure credentials exist before publishing (idempotent)\nspacetime login\nspacetime publish mydb\n# And drop --anonymous from every scripted invocation","typeGuard":null,"tryCatchPattern":"If wrapping the CLI: on failure, if stderr matches \"You need to be logged in as the owner\", run `spacetime login` once and retry the publish a single time","preventionTips":["Run `spacetime login` as an explicit CI step before any publish.","Never combine --anonymous with a named database you expect to own.","Verify the target server (`spacetime server list`) matches the account that owns the database name."],"tags":["publish","authentication","permissions","identity","anonymous"],"backgroundTag":"authentication-required","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"}