{"record":{"id":"67653751c5a860e9","repo":"BoundaryML/baml","slug":"split-method-takes-exactly-1-argument-at","errorCode":null,"errorMessage":"split() method takes exactly 1 argument at {:?}","messagePattern":"split\\(\\) method takes exactly 1 argument at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":2933,"sourceCode":"                );\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);\n            };\n            let parts: Vec<BamlValueWithMeta<ExprMetadata>> = s\n                .split(delimiter.as_str())\n                .map(|part| BamlValueWithMeta::String(part.to_string(), meta.clone()))\n                .collect();\n            Ok(BamlValueWithMeta::List(parts, meta.clone()))\n        }\n        \"substring\" => {\n            let BamlValueWithMeta::String(s, _) = receiver else {\n                bail!(\n                    \"substring() method only available on strings at {:?}\",\n                    meta.0\n                );\n            };\n            if args.len() != 2 {","sourceCodeStart":2915,"sourceCodeEnd":2951,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2915-L2951","documentation":"The split method requires exactly one argument (the delimiter). If a call passes zero arguments or more than one, the interpreter bails with this message. The library enforces the fixed signature split(delimiter).","triggerScenarios":"Calling s.split() with no delimiter, or s.split(\",\", 3) with an extra limit argument, in BAML expression code.","commonSituations":"Porting code from languages where split accepts an optional limit or regex; omitting the delimiter assuming a default whitespace split; dynamic argument arrays with an extra element.","solutions":["Provide exactly one string delimiter: s.split(\",\").","If you need a max-parts behavior, post-process the result (e.g. rejoin and split again) instead of passing a second argument.","Remove any extra arguments at the failing call site."],"exampleFix":"// before\nlet parts = s.split(\",\", 3);\n\n// after\nlet parts = s.split(\",\");","handlingStrategy":"validation","validationCode":"// split takes exactly one string delimiter argument\nlet args_ok = args.len() == 1;","typeGuard":null,"tryCatchPattern":"match result {\n  Err(e) if e.to_string().contains(\"takes exactly 1 argument\") => log_missing_arg(\"split\"),\n  other => other,\n}","preventionTips":["BAML split has no default delimiter — always supply one explicitly.","No limit/max-splits parameter exists; post-process the resulting list if needed.","Don't copy multi-arg split conventions from other languages."],"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"}