{"record":{"id":"1b41ccc8596f4510","repo":"BoundaryML/baml","slug":"endswith-method-takes-exactly-1-argument-at","errorCode":null,"errorMessage":"endsWith() method takes exactly 1 argument at {:?}","messagePattern":"endsWith\\(\\) method takes exactly 1 argument at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":2918,"sourceCode":"                );\n            }\n            let BamlValueWithMeta::String(prefix, _) = &args[0] else {\n                bail!(\"startsWith() argument must be a string at {:?}\", meta.0);\n            };\n            Ok(BamlValueWithMeta::Bool(\n                s.starts_with(prefix.as_str()),\n                meta.clone(),\n            ))\n        }\n        \"endsWith\" => {\n            let BamlValueWithMeta::String(s, _) = receiver else {\n                bail!(\n                    \"endsWith() method only available on strings at {:?}\",\n                    meta.0\n                );\n            };\n            if args.len() != 1 {\n                bail!(\"endsWith() method takes exactly 1 argument at {:?}\", meta.0);\n            }\n            let BamlValueWithMeta::String(suffix, _) = &args[0] else {\n                bail!(\"endsWith() argument must be a string at {:?}\", meta.0);\n            };\n            Ok(BamlValueWithMeta::Bool(\n                s.ends_with(suffix.as_str()),\n                meta.clone(),\n            ))\n        }\n        \"split\" => {\n            let BamlValueWithMeta::String(s, _) = receiver else {\n                bail!(\"split() method only available on strings at {:?}\", meta.0);\n            };\n            if args.len() != 1 {\n                bail!(\"split() method takes exactly 1 argument at {:?}\", meta.0);\n            }\n            let BamlValueWithMeta::String(delimiter, _) = &args[0] else {\n                bail!(\"split() argument must be a string at {:?}\", meta.0);","sourceCodeStart":2900,"sourceCodeEnd":2936,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2900-L2936","documentation":"When the interpreter handles the \"endsWith\" string method it requires exactly one argument (the suffix to test). If the call site passed zero or multiple arguments, it bails with this message before evaluating anything. The library enforces the fixed arity of endsWith(suffix).","triggerScenarios":"Calling str.endsWith() with no arguments, or str.endsWith(\"a\", \"b\") with more than one argument, inside a BAML expression evaluated by evaluate_method_call.","commonSituations":"Copying split/substring-style multi-argument calling conventions to endsWith; concatenating argument lists dynamically and accidentally passing an extra element; forgetting the suffix argument entirely.","solutions":["Pass exactly one string argument: s.endsWith(suffix).","If you intended multiple suffixes, call endsWith once per suffix and combine with ||.","Count the arguments at the failing call site and remove extras or supply the missing suffix."],"exampleFix":"// before\nlet ok = s.endsWith(\"a\", \"b\");\n\n// after\nlet ok = s.endsWith(\"a\") || s.endsWith(\"b\");","handlingStrategy":"validation","validationCode":"// assert arity before calling\n// endsWith takes exactly 1 argument\nlet args_ok = args.len() == 1;","typeGuard":null,"tryCatchPattern":"// catch and report arity problems\nmatch result {\n  Err(e) if e.to_string().contains(\"takes exactly 1 argument\") => log_missing_arg(\"endsWith\"),\n  other => other,\n}","preventionTips":["Remember BAML endsWith takes one argument only — no regex, no limit parameter.","For multiple suffixes, chain separate endsWith calls instead of passing a list.","Review call sites after refactoring argument lists."],"tags":["baml","argument-count","string-method","arity"],"backgroundTag":"missing-required-argument","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}