{"record":{"id":"a5302ecb532fae2f","repo":"clockworklabs/SpacetimeDB","slug":"internal-error-function-name-should-be-present-af","errorCode":null,"errorMessage":"internal error: function_name should be present after argument resolution","messagePattern":"internal error: function_name should be present after argument resolution","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/call.rs","lineNumber":82,"sourceCode":"    let anon_identity = args.get_flag(\"anon_identity\");\n    let no_config = args.get_flag(\"no_config\");\n\n    let raw_parts: Vec<String> = args\n        .get_many::<String>(\"call_parts\")\n        .map(|vals| vals.cloned().collect())\n        .unwrap_or_default();\n\n    let config_targets = load_config_db_targets(no_config)?;\n    let resolved = resolve_optional_database_parts(\n        &raw_parts,\n        config_targets.as_deref(),\n        \"function_name\",\n        \"spacetime call [database] <function_name> <arguments>... (or --no-config for legacy behavior)\",\n    )?;\n    let reducer_procedure_name = resolved\n        .remaining_args\n        .first()\n        .ok_or_else(|| anyhow::anyhow!(\"internal error: function_name should be present after argument resolution\"))?;\n    let call_arguments = resolved.remaining_args.iter().skip(1);\n    let resolved_server = server.or(resolved.server.as_deref());\n\n    let mut config = config;\n    let conn = crate::api::Connection {\n        host: config.get_host_url(resolved_server)?,\n        auth_header: get_auth_header(&mut config, anon_identity, resolved_server, !force).await?,\n        database_identity: database_identity(&config, &resolved.database, resolved_server).await?,\n        database: resolved.database.clone(),\n    };\n    let api = ClientApi::new(conn);\n\n    let database_identity = api.con.database_identity;\n    let database = &api.con.database;\n\n    let module_def: ModuleDef = api.module_def().await?.try_into()?;\n\n    // Dot-qualified names (e.g. `lib.my_reducer`) route to submodules.","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/subcommands/call.rs#L64-L100","documentation":"In `spacetime call` (crates/cli/src/subcommands/call.rs:82), after resolve_optional_database_parts succeeds, the code takes resolved.remaining_args.first() as the reducer name. Inspection of the resolver (crates/cli/src/subcommands/db_arg_resolution.rs:84-148) shows every success path returns at least one remaining arg when required_arg_name is enforced, so this bail is a defensive internal-invariant check that should be unreachable. Hitting it means argument resolution returned Ok with an empty remaining_args - a CLI bug, not a user input shape the resolver documents.","triggerScenarios":"Running `spacetime call` in some boundary configuration where the resolver matches a config target but yields no remaining arguments - per the current resolver code there is no legal input that does this, so occurrences indicate a regression or an unusual invocation path (e.g. an empty-string positional argument edge case).","commonSituations":"New CLI versions where resolver behavior changed and this invariant broke; scripts passing empty or whitespace positional args; reporting a SpacetimeDB CLI bug with the exact command line.","solutions":["Re-run with fully explicit arguments: `spacetime call <database> <function_name> <args...> --no-config` to bypass config-target resolution entirely.","Update to the latest CLI version in case the invariant break is already fixed.","If it reproduces, file an issue in the SpacetimeDB repo including the exact command line, spacetime.json (databases section), and CLI version - the 'internal error' prefix means the maintainers consider it unreachable."],"exampleFix":"# before: triggers internal resolution bug\nspacetime call my-reducer\n# after: bypass config resolution with explicit parts\nspacetime call my-db my-reducer '[]' --no-config","handlingStrategy":"validation","validationCode":"// Shell: require an explicit function name so resolution always has a remaining arg.\n[ $# -ge 1 ] || { echo 'usage: spacetime call [database] <function_name> <args>...' >&2; exit 2; }\nspacetime call \"$@\" --no-config","typeGuard":null,"tryCatchPattern":"// Treat as a bug, not a retryable condition:\nlet out = run_spacetime([\"call\", ...]).context(\"spacetime call failed\")?;\nif out.contains(\"internal error: function_name should be present\") {\n    anyhow::bail!(\"CLI bug: please report at https://github.com/clockworklabs/SpacetimeDB/issues with this command line\");\n}","preventionTips":["Always pass the reducer name explicitly rather than relying on config inference in scripts.","Pin and periodically update the CLI version; internal-invariant breaks get fixed upstream.","When it reproduces, capture the exact argv and the spacetime.json databases section for the bug report."],"tags":["spacetimedb","cli","internal-error","argument-resolution","bug"],"backgroundTag":"cli-argument-resolution-bug","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}