Skip to content

spacetime publish: -c/--delete-data breaks the spacetime.json database-name fallback #5253

Description

@krisajenkins

Summary

spacetime publish reads the database name from spacetime.json when no positional argument is given, but adding -c/--delete-data defeats that fallback and the parser errors out demanding <name|identity>.

Reproducer

spacetime.json:

{
  "server": "local",
  "database": "space-transactions",
  "module-path": "./module"
}
Invocation Result
spacetime publish ✅ uses space-transactions from config
spacetime publish --yes ✅ uses config name
spacetime publish -c=always ❌ `error: required arguments not provided: <name
spacetime publish -c=always --yes ❌ same error
spacetime publish -c=always space-transactions ✅ works

--yes alone is fine. The failure is exclusively triggered by -c/--delete-data.

Exact error:

$ spacetime publish -c=always
error: the following required arguments were not provided:
  <name|identity>

Usage: spacetime publish --delete-data[=<clear-database>] <name|identity>

Tested against spacetimedb tool version 2.4.1; spacetimedb-lib version 2.4.1.

Cause

In crates/cli/src/subcommands/publish.rs the clear_database arg carries a clap-level .requires(\"name|identity\"):

.arg(
    common_args::clear_database()
        .requires(\"name|identity\")
)

That constraint fires during clap parsing — before the config-driven name fallback runs. The rest of the file already understands the name can come from config:

  • publish.rs:87Key::new(\"database\").from_clap(\"name|identity\").required() marks the name as required at the schema layer (satisfiable by clap or config).
  • publish.rs:484-485name_or_identity is read from the merged CommandConfig (clap + spacetime.json).

So bare spacetime publish works because the schema-layer check sees the config value. -c=always short-circuits that by failing clap parsing first.

The .requires predates the config-driven Key schema infrastructure — git log -L 195,197:crates/cli/src/subcommands/publish.rs traces it back through PR #3601 (move to common_args::clear_database()) and PR #1880 (name|addressname|identity rename). The config-fallback layer was added later without revisiting it.

Suggested fix

Drop the clap-level .requires(\"name|identity\"). The schema/config merge already enforces "must know which database" — validate_name_and_parent at publish.rs:531 returns an error cleanly if name_or_identity is still None after the merge. Data destruction is gated by the confirmation prompt regardless, so the constraint isn't load-bearing for safety.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions