risingwavelabs/risingwave · error
invalid variant path `{original_path}`
Error message
invalid variant path `{original_path}` What it means
The variant path parser tokenizes strings like `.a.b` or `['x']` into PathToken::Field / PathToken::Index. Inside a bare identifier (after '.'), an empty field name is invalid; when the loop ends and `field` is empty, the whole original path is rejected with this error.
Source
Thrown at src/common/src/types/variant.rs:924
fn parse_path(path: &str) -> anyhow::Result<Vec<PathToken>> {
let original_path = path;
let path = path.strip_prefix('$').unwrap_or(path);
let mut chars = path.chars().peekable();
let mut tokens = vec![];
while let Some(ch) = chars.next() {
match ch {
'.' => {
let mut field = String::new();
while let Some(&c) = chars.peek() {
if c == '.' || c == '[' {
break;
}
field.push(c);
chars.next();
}
if field.is_empty() {
bail!("invalid variant path `{original_path}`");
}
tokens.push(PathToken::Field(field));
}
'[' => {
if matches!(chars.peek(), Some('\'') | Some('"')) {
let quote = chars.next().unwrap();
let mut field = String::new();
let mut closed = false;
for c in chars.by_ref() {
if c == quote {
closed = true;
break;
}
field.push(c);
}
if !closed || chars.next() != Some(']') {
bail!("invalid variant path `{original_path}`");
}View on GitHub (pinned to 6469eb736d)
Solutions
- Remove empty segments from the path (no `..`, no trailing `.`)
- Validate the path string before calling the parser (reject empty identifiers)
- Quote fields that are empty or contain special characters, e.g. `a['']` only if truly intended
Example fix
// before let path = "a..b"; // invalid // after let path = "a.b";
Defensive patterns
Strategy: validation
Validate before calling
fn path_has_no_empty_fields(path: &str) -> bool {
let body: &str = path.strip_prefix('.').unwrap_or(path);
!body.is_empty() && !body.contains("..") && !body.ends_with('.')
} Try / catch
match parse_variant_path(path) {
Ok(tokens) => tokens,
Err(e) if e.to_string().contains("invalid variant path") => Vec::new(),
Err(e) => return Err(e),
} Prevention
- Never concatenate path segments blindly; join with '.' only for non-empty fields
- Validate user-supplied JSON paths with a regex before parsing
- Strip trailing separators from dynamically built paths
When it happens
Trigger: Calling the variant path parser with paths like `a..b`, `a.` (trailing dot creates empty field), or a path that is just `.` / ends with a separator producing an empty field token.
Common situations: Dynamically built paths (string concatenation) that accidentally include empty segments, user-supplied JSON path expressions with typos.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- unsupported JSON number: {v}
- cannot convert {} as {ty} to variant
- variant object cannot have duplicate field name `{field_name
- Invalid variant encoding
- creating an Iceberg table with VARIANT column `{}` requires
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/8b9ffafb61c90b68.
Report an issue: GitHub.