BoundaryML/baml · error

toUpperCase() method takes no arguments at

Error message

toUpperCase() method takes no arguments at {:?}

What it means

toUpperCase() in BAML takes no arguments; passing any argument to it makes evaluate_method_call bail. The method intentionally mirrors the zero-argument JavaScript/Rust to_uppercase, so any parenthesized argument is a compile/interpret-time error.

Solutions

  1. Remove the argument and call it as a no-argument method: `s.toUpperCase()`.
  2. If locale- or prefix-specific casing was intended, perform that transformation outside BAML in the host language before passing the string in.
  3. Check you didn't mean a different method — e.g. includes() or startsWith() do take one argument.

Example fix

// before
let upper = name.toUpperCase("en-US");
// after
let upper = name.toUpperCase();
Defensive patterns

Strategy: validation

Validate before calling

// lint your BAML sources before running
const bad = src.match(/\.toUpperCase\s*\(\s*[^)]+/);
if (bad) throw new Error('toUpperCase() takes no arguments: ' + bad[0]);

Try / catch

try {
  const res = await b.Function(args);
} catch (e) {
  if (String(e.message).includes('toUpperCase() method takes no arguments')) {
    // strip the argument at the reported span and re-run
  }
  throw e;
}

Prevention

When it happens

Trigger: Writing `s.toUpperCase(arg)` — with any number of arguments (even an empty literal or another string) — inside a BAML expression block or template expression.

Common situations: Develpers coming from languages where case-conversion takes a locale/culture argument (e.g. Java's toUpperCase(Locale)) pass an argument out of habit; copying a pattern from another string method like includes() that does take an argument.

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 BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/e2f659e27ccfdb8d. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-compiler/src/thir/interpret.rs:2855

                bail!(
                    "toLowerCase() method only available on strings at {:?}",
                    meta.0
                );
            };
            if !args.is_empty() {
                bail!("toLowerCase() method takes no arguments at {:?}", meta.0);
            }
            Ok(BamlValueWithMeta::String(s.to_lowercase(), meta.clone()))
        }
        "toUpperCase" => {
            let BamlValueWithMeta::String(s, _) = receiver else {
                bail!(
                    "toUpperCase() method only available on strings at {:?}",
                    meta.0
                );
            };
            if !args.is_empty() {
                bail!("toUpperCase() method takes no arguments at {:?}", meta.0);
            }
            Ok(BamlValueWithMeta::String(s.to_uppercase(), meta.clone()))
        }
        "trim" => {
            let BamlValueWithMeta::String(s, _) = receiver else {
                bail!("trim() method only available on strings at {:?}", meta.0);
            };
            if !args.is_empty() {
                bail!("trim() method takes no arguments at {:?}", meta.0);
            }
            Ok(BamlValueWithMeta::String(
                s.trim().to_string(),
                meta.clone(),
            ))
        }
        "includes" => {
            let BamlValueWithMeta::String(s, _) = receiver else {
                bail!(

View on GitHub (pinned to bd85ce9dee)