wavetermdev/waveterm · error
Invalid path part: ${pathPart}
Error message
Invalid path part: ${pathPart} What it means
getPath walks an ijson object along a path array of keys/indices. When a segment is a string (object key) but the current node is neither an object nor an array-compatible structure — i.e. the key type doesn't match the node type — it throws "Invalid path part". Note the visible branch throws when the segment is otherwise unusable on the current value.
Source
Thrown at frontend/util/ijson.ts:59
let cur = obj;
for (const pathPart of path) {
if (cur == null) {
return null;
}
if (typeof pathPart === "string") {
if (isObject(cur)) {
cur = cur[pathPart];
} else {
return null;
}
} else if (typeof pathPart === "number") {
if (isArray(cur)) {
cur = cur[pathPart];
} else {
return null;
}
} else {
throw new Error("Invalid path part: " + pathPart);
}
}
return cur;
}
type SetPathOpts = {
force?: boolean;
remove?: boolean;
combinefn?: (oldVal: any, newVal: any, opts: SetPathOpts) => any;
};
function combineFn_arrayAppend(oldVal: any, newVal: any, opts: SetPathOpts): any {
if (oldVal == null) {
return [newVal];
}
if (!isArray(oldVal) && !opts.force) {
throw new Error("Cannot append to non-array: " + oldVal);
}View on GitHub (pinned to a4447c1563)
Solutions
- Verify the object's actual shape at each path segment before deep traversal
- Use optional access (getPath already returns null for array mismatch) or guard segments against the node type
- Fix the path construction so keys match the real nesting of the ijson atom
Example fix
// before getPath(atom, ["meta", "sub", "key"]); // after const mid = getPath(atom, ["meta"]); const val = mid && typeof mid === "object" ? getPath(atom, ["meta", "sub", "key"]) : null;
Defensive patterns
Strategy: validation
Validate before calling
const cur = getPath(obj, ["meta"]); if (cur == null || typeof cur !== "object") return null; // don't traverse further
Type guard
function isTraversable(v: unknown): v is Record<string, unknown> {
return v != null && typeof v === "object";
} Try / catch
let value;
try {
value = getPath(atom, path);
} catch (e) {
if (String(e.message).startsWith("Invalid path part")) {
value = null; // treat as missing
} else { throw e; }
} Prevention
- Build paths from the actual observed shape of the atom, not assumed schemas
- Check intermediate values before deep path traversal
- Prefer returning null for missing branches and reserve throwing for true type mismatches
When it happens
Trigger: Calling getPath(obj, path) where a string pathPart is applied to a node that is not an object (e.g. traversing into a primitive, null, or a string key on a non-container).
Common situations: Assuming a nested field exists when an intermediate value is a primitive; schema drift between the expected atom/JSON shape and actual data; passing a path built for one object shape to another.
Related errors
- file %s:%s is not an ijson file
- Invalid command path: ${formatPath(path)}
- Invalid command type: ${commandType}
- convertFileUIMessagePart expects 'file' type, got '%s'
- convertFileAIMessagePart expects 'file' type, got '%s'
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/f01891ddd8e77177.
Report an issue: GitHub.