clockworklabs/SpacetimeDB · error

the following required arguments were not provided: <{}>

Error message

the following required arguments were not provided:
  <{}>

Usage: {}

What it means

resolve_optional_database_parts, in its no-config branch, reproduces clap's 'missing required arguments' error by hand: when there are no config targets, zero positional parts demand <database>, and a single positional part demands the command-specific required argument (required_arg_name, supplied by the calling subcommand). The Usage string is provided by the caller, so the message always shows the exact syntax for the command you ran.

Source

Thrown at crates/cli/src/subcommands/db_arg_resolution.rs:91

                    Some(ConfigDbTarget {
                        database: database.to_string(),
                        server,
                    })
                })
                .unique_by(|t| t.database.clone())
                .collect::<Vec<_>>()
        })
        .filter(|targets| !targets.is_empty()))
}

pub(crate) fn resolve_optional_database_parts(
    raw_parts: &[String],
    config_targets: Option<&[ConfigDbTarget]>,
    required_arg_name: &str,
    usage: &str,
) -> anyhow::Result<ResolvedDbArgs> {
    let require_arg = |name: &str| {
        anyhow::anyhow!(
            "the following required arguments were not provided:\n  <{}>\n\nUsage: {}",
            name,
            usage
        )
    };

    let Some(config_targets) = config_targets else {
        if raw_parts.len() < 2 {
            return if raw_parts.is_empty() {
                Err(require_arg("database"))
            } else {
                Err(require_arg(required_arg_name))
            };
        }
        return Ok(ResolvedDbArgs {
            database: raw_parts[0].clone(),
            server: None,
            remaining_args: raw_parts[1..].to_vec(),

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Supply the missing positional(s) exactly as shown in the Usage line of the error
  2. Run the command from within the project so spacetime.json supplies the database default
  3. Drop --no-config if you did intend to use the project's defaults

Example fix

# before (outside any project)
spacetime describe

# after
spacetime describe mydb reducer my_reducer
Defensive patterns

Strategy: validation

Validate before calling

# Enforce the positional contract before invoking a two-positional command
if [ $# -lt 2 ]; then
  echo "usage: $0 <database> <$(basename "$0" -wrapper)>" >&2; exit 2
fi
spacetime describe "$1" "$2" "$3"

Type guard

fn valid_positionals(parts: &[String]) -> bool {
    !parts.is_empty() && parts.len() >= 2
}

Try / catch

let out = cmd.output()?;
if !out.status.success() && String::from_utf8_lossy(&out.stderr).contains("required arguments were not provided") {
    // print the Usage line from the message and surface it as a usage error (exit 2)
}

Prevention

When it happens

Trigger: Running a command that takes a database plus a required trailing argument (usage shown in the error) with too few positionals, while no spacetime.json supplies defaults — e.g. outside a project or with --no-config.

Common situations: Running CLI commands from $HOME or a non-project directory and assuming flags replace positionals; adding --no-config to a command that then loses config-supplied defaults; scripts written against a project context but run standalone.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/86ecea289a471f39. Report an issue: GitHub.