influxdata/influxdb · error · Error
Could not find '_'
Error message
Could not find '_'
What it means
split_namespace parses a 'org_id_bucket_id' namespace string into its two components by splitting on '_'. This error is thrown when the iterator is exhausted after extracting the org_id, meaning the string contained no '_' separator (or ended immediately after it), so no bucket_id segment exists. The library requires exactly one underscore separating the two identifiers.
Solutions
- Ensure the namespace string is in '<org_id>_<bucket_id>' form with a non-empty bucket_id after the underscore
- Validate the format before calling: check the string contains exactly one '_' and that both segments are non-empty
- Fix upstream code or configuration that is passing only the org-level identifier instead of the fully qualified namespace
Example fix
// before
let (org, bucket) = split_namespace("myorg")?; // panics/errors: no '_'
// after
let (org, bucket) = split_namespace("myorg_mybucket")?; Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_namespace(ns: &str) -> bool {
match ns.split_once('_') {
Some((org, bucket)) => !org.is_empty() && !bucket.is_empty(),
None => false,
}
} Type guard
fn valid_namespace(ns: &str) -> Option<(&str, &str)> {
ns.split_once('_').filter(|(o, b)| !o.is_empty() && !b.is_empty())
} Try / catch
match split_namespace(ns) {
Ok((org, bucket)) => /* ... */,
Err(e) => eprintln!("invalid namespace '{}': {}", ns, e),
} Prevention
- Always build namespace strings with format!("{}_{}", org_id, bucket_id) from typed components instead of concatenating user input
- Reject namespaces without an underscore at system boundaries
- Never store bare org-level names where a fully qualified namespace is expected
When it happens
Trigger: Calling split_namespace with a namespace string that contains no '_' at all (e.g. "myorg") or ends with a trailing '_' where the split yields an empty remainder consumed before the empty check can produce a distinct message. Test callers split_bad_only_underscore and similar exercise these paths.
Common situations: Passing an unqualified namespace name (just the org or database name) where the API expects the full 'org_bucket' qualified form; string truncation upstream that dropped the suffix after the underscore; hand-built namespace strings in config or tooling missing the bucket segment.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- More than one '_'
- No bucket_id found
- is not a valid data type, values are int64, uint64…
- Invalid database ID
- invalid namespace name
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/b7340c00846986e0.
Report an issue: GitHub.
Appendix: source
Thrown at core/client_util/src/namespace_translation.rs:33
Self::InvalidNamespace {
namespace: namespace.into(),
reason: reason.into(),
}
}
}
/// Splits up the namespace name into org_id and bucket_id
pub fn split_namespace(namespace: &str) -> Result<(&str, &str), Error> {
let mut iter = namespace.split('_');
let org_id = iter.next().ok_or_else(|| Error::new(namespace, "empty"))?;
if org_id.is_empty() {
return Err(Error::new(namespace, "No org_id found"));
}
let bucket_id = iter
.next()
.ok_or_else(|| Error::new(namespace, "Could not find '_'"))?;
if bucket_id.is_empty() {
return Err(Error::new(namespace, "No bucket_id found"));
}
if iter.next().is_some() {
return Err(Error::new(namespace, "More than one '_'"));
}
Ok((org_id, bucket_id))
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn split_good() {View on GitHub (pinned to 06200ef96b)