risingwavelabs/risingwave · error · ExprError

too few arguments for format()

Error message

too few arguments for format()

What it means

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.

Solutions

  1. Add the missing argument(s) to match the placeholder count.
  2. Remove or escape the extra placeholders in the format string.
  3. Validate template/argument arity in application code when templates are dynamic.

Example fix

// before
SELECT format('%s-%s', id) FROM t;
// after
SELECT format('%s-%s', id, seq) FROM t;
Defensive patterns

Strategy: validation

Validate before calling

// count placeholders vs args before calling format
let placeholders = template.matches('%').count();
assert_eq!(placeholders, args.len(), "format arity mismatch");

Try / catch

// Catch arity errors and surface the template for debugging
if err.to_string().contains("too few arguments for format()") {
    return Err(anyhow!("template `{template}` needs more arguments"));
}

Prevention

When it happens

Trigger: `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.

Common situations: Hand-edited format templates, templates loaded from config where placeholders were added but call sites not updated, i18n string templates with different placeholder counts.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/4fa5dcf228ffe1f3. Report an issue: GitHub.

Appendix: source

Thrown at src/expr/core/src/error.rs:108

    /// TODO: deprecate in favor of `Function`
    #[error(transparent)]
    Internal(
        #[from]
        #[backtrace]
        anyhow::Error,
    ),

    #[error("not a constant")]
    NotConstant,

    #[error("Context {0} not found")]
    Context(&'static str),

    #[error("field name must not be null")]
    FieldNameNull,

    #[error("too few arguments for format()")]
    TooFewArguments,

    #[error(
        "null value in column \"{col_name}\" of relation \"{table_name}\" violates not-null constraint"
    )]
    NotNullViolation {
        col_name: Box<str>,
        table_name: Box<str>,
    },

    #[error("invalid state: {0}")]
    InvalidState(String),

    /// Function error message returned by UDF.
    /// TODO: replace with `Function`
    #[error("{0}")]
    Custom(String),

View on GitHub (pinned to 6469eb736d)