{"record":{"id":"4fa5dcf228ffe1f3","repo":"risingwavelabs/risingwave","slug":"too-few-arguments-for-format","errorCode":null,"errorMessage":"too few arguments for format()","messagePattern":"too few arguments for format\\(\\)","errorType":"exception","errorClass":"ExprError","httpStatus":null,"severity":"error","filePath":"src/expr/core/src/error.rs","lineNumber":108,"sourceCode":"\n    /// TODO: deprecate in favor of `Function`\n    #[error(transparent)]\n    Internal(\n        #[from]\n        #[backtrace]\n        anyhow::Error,\n    ),\n\n    #[error(\"not a constant\")]\n    NotConstant,\n\n    #[error(\"Context {0} not found\")]\n    Context(&'static str),\n\n    #[error(\"field name must not be null\")]\n    FieldNameNull,\n\n    #[error(\"too few arguments for format()\")]\n    TooFewArguments,\n\n    #[error(\n        \"null value in column \\\"{col_name}\\\" of relation \\\"{table_name}\\\" violates not-null constraint\"\n    )]\n    NotNullViolation {\n        col_name: Box<str>,\n        table_name: Box<str>,\n    },\n\n    #[error(\"invalid state: {0}\")]\n    InvalidState(String),\n\n    /// Function error message returned by UDF.\n    /// TODO: replace with `Function`\n    #[error(\"{0}\")]\n    Custom(String),\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/core/src/error.rs#L90-L126","documentation":"ExprError::TooFewArguments is thrown when a format()-style function (string formatting analogous to Postgres `format`) is given fewer arguments than its format string consumes. Each placeholder in the template needs a corresponding argument; the count mismatch is detected at evaluation time.","triggerScenarios":"`format('a %s b %s', x)` with only one argument for two placeholders; dynamically built format strings whose placeholder count drifted from the argument list.","commonSituations":"Hand-edited format templates, templates loaded from config where placeholders were added but call sites not updated, i18n string templates with different placeholder counts.","solutions":["Add the missing argument(s) to match the placeholder count.","Remove or escape the extra placeholders in the format string.","Validate template/argument arity in application code when templates are dynamic."],"exampleFix":"// before\nSELECT format('%s-%s', id) FROM t;\n// after\nSELECT format('%s-%s', id, seq) FROM t;","handlingStrategy":"validation","validationCode":"// count placeholders vs args before calling format\nlet placeholders = template.matches('%').count();\nassert_eq!(placeholders, args.len(), \"format arity mismatch\");","typeGuard":null,"tryCatchPattern":"// Catch arity errors and surface the template for debugging\nif err.to_string().contains(\"too few arguments for format()\") {\n    return Err(anyhow!(\"template `{template}` needs more arguments\"));\n}","preventionTips":["Keep format templates and argument lists adjacent in code reviews.","When templates come from config, validate placeholder count at load time.","Escape literal % signs so they are not counted as placeholders."],"tags":["rust","format","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}