{"record":{"id":"1aa455b03b9194c9","repo":"influxdata/influxdb","slug":"more-than-one","errorCode":null,"errorMessage":"More than one '_'","messagePattern":"More than one '_'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/client_util/src/namespace_translation.rs","lineNumber":40,"sourceCode":"/// Splits up the namespace name into org_id and bucket_id\npub fn split_namespace(namespace: &str) -> Result<(&str, &str), Error> {\n    let mut iter = namespace.split('_');\n    let org_id = iter.next().ok_or_else(|| Error::new(namespace, \"empty\"))?;\n\n    if org_id.is_empty() {\n        return Err(Error::new(namespace, \"No org_id found\"));\n    }\n\n    let bucket_id = iter\n        .next()\n        .ok_or_else(|| Error::new(namespace, \"Could not find '_'\"))?;\n\n    if bucket_id.is_empty() {\n        return Err(Error::new(namespace, \"No bucket_id found\"));\n    }\n\n    if iter.next().is_some() {\n        return Err(Error::new(namespace, \"More than one '_'\"));\n    }\n\n    Ok((org_id, bucket_id))\n}\n\n#[cfg(test)]\nmod test {\n    use super::*;\n\n    #[test]\n    fn split_good() {\n        assert_eq!(split_namespace(\"foo_bar\").unwrap(), (\"foo\", \"bar\"));\n    }\n\n    #[test]\n    #[should_panic(expected = \"No org_id found\")]\n    fn split_bad_empty() {\n        split_namespace(\"\").unwrap();","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/client_util/src/namespace_translation.rs#L22-L58","documentation":"split_namespace enforces that the namespace string contains exactly one '_' separator. If the iterator still yields another segment after extracting org_id and bucket_id, the string had multiple underscores (e.g. \"a_b_c\") and this error is thrown, because org or bucket ids cannot contain underscores under this encoding.","triggerScenarios":"Calling split_namespace with strings containing two or more underscores such as \"my_org_bucket\" or \"a_b_c_d\"; exercised by tests split_too_many and split_way_too_many.","commonSituations":"Org or bucket names that themselves contain underscores being joined with '_'; users assuming multi-underscore names are supported; legacy identifiers not migrated to the underscore-free scheme.","solutions":["Use namespace strings with exactly one underscore: '<org_id>_<bucket_id>' where neither id contains '_'","Rename org/bucket identifiers to exclude underscores, or use a different delimiter/encoding if the scheme allows","Pre-validate with a check that s.match_indices('_').count() == 1 before calling"],"exampleFix":"// before\nlet (org, bucket) = split_namespace(\"my_org_mybucket\")?; // two '_'\n// after\nlet (org, bucket) = split_namespace(\"myorg_mybucket\")?; // exactly one '_'","handlingStrategy":"validation","validationCode":"fn exactly_one_underscore(ns: &str) -> bool {\n    ns.match_indices('_').count() == 1\n}","typeGuard":"fn safe_split(ns: &str) -> Option<(&str, &str)> {\n    let mut it = ns.split('_');\n    let org = it.next()?;\n    let bucket = it.next()?;\n    it.next().is_none().then(|| (org, bucket))\n}","tryCatchPattern":"match split_namespace(ns) {\n    Ok((org, bucket)) => /* ... */,\n    Err(e) if e.to_string().contains(\"More than one\") => eprintln!(\"namespace '{}' has embedded underscores\", ns),\n    Err(e) => eprintln!(\"{}\", e),\n}","preventionTips":["Enforce that org_id and bucket_id never contain '_' at creation time","Escape or encode identifiers that may contain underscores before embedding in namespaces","Add a unit test that round-trips every generated namespace through split_namespace"],"tags":["rust","parsing","namespace","invalid-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}