BloopAI/vibe-kanban · error
Workspace path should be valid
Error message
Workspace path should be valid
What it means
This panic comes from an `.expect()` on the JSON Pointer string conversion in `workspace_patch::add` (crates/services/src/services/events/patches.rs:70). `workspace_path()` builds a pointer of the form "/workspaces/<uuid>" with `~` and `/` escaped via `escape_pointer_segment`, so `try_into()` into the json_patch `Pointer` type should always succeed. The panic only fires if the constructed path is not a valid JSON Pointer (not starting with `/` or containing unescaped invalid segments), which indicates a bug in the path-building helper rather than bad caller input.
Source
Thrown at crates/services/src/services/events/patches.rs:70
}
}
/// Helper functions for creating workspace-specific patches
pub mod workspace_patch {
use super::*;
fn workspace_path(workspace_id: Uuid) -> String {
format!(
"/workspaces/{}",
escape_pointer_segment(&workspace_id.to_string())
)
}
pub fn add(workspace: &WorkspaceWithStatus) -> Patch {
Patch(vec![PatchOperation::Add(AddOperation {
path: workspace_path(workspace.id)
.try_into()
.expect("Workspace path should be valid"),
value: serde_json::to_value(workspace)
.expect("Workspace serialization should not fail"),
})])
}
pub fn replace(workspace: &WorkspaceWithStatus) -> Patch {
Patch(vec![PatchOperation::Replace(ReplaceOperation {
path: workspace_path(workspace.id)
.try_into()
.expect("Workspace path should be valid"),
value: serde_json::to_value(workspace)
.expect("Workspace serialization should not fail"),
})])
}
pub fn remove(workspace_id: Uuid) -> Patch {
Patch(vec![PatchOperation::Remove(RemoveOperation {
path: workspace_path(workspace_id)View on GitHub (pinned to 4deb7eca8f)
Solutions
- Verify `workspace_path` returns a string starting with `/` with a properly escaped segment: "/workspaces/<escaped-uuid>".
- Ensure `escape_pointer_segment` is applied to any non-UUID segment (replace `~` with `~0` and `/` with `~1`).
- If a custom path was introduced, validate it with `Pointer::try_from(...)` and handle the error instead of `.expect()`.
- Run the crate's unit tests for `workspace_patch::add` to confirm the path round-trips through json_patch.
Example fix
// before
path: workspace_path(workspace.id)
.try_into()
.expect("Workspace path should be valid"),
// after
let path = workspace_path(workspace.id);
let path: json_patch::Pointer = path.try_into().unwrap_or_else(|e| {
panic!("invalid JSON pointer {:?}: {}", path, e)
});
// (or fix workspace_path to always emit "/workspaces/<escaped-id>") Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_workspace_pointer(id: uuid::Uuid) -> bool {
let p = format!("/workspaces/{}", id);
json_patch::Pointer::try_from(p).is_ok()
}
// assert before building the patch:
assert!(is_valid_workspace_pointer(workspace.id)); Type guard
fn valid_pointer(s: &str) -> Option<json_patch::Pointer> {
json_patch::Pointer::try_from(s.to_string()).ok()
} Prevention
- Never interpolate unescaped `/` or `~` into JSON Pointer segments.
- Always run segments through escape_pointer_segment (~0/~1 escaping).
- Add a unit test asserting the pointer converts via Pointer::try_from.
- Treat .expect() on path building as a code invariant, not runtime error handling.
When it happens
Trigger: Calling `workspace_patch::add(&WorkspaceWithStatus)` where the internal `workspace_path(workspace.id).try_into()` conversion fails; practically this happens only if `workspace_path` is changed to emit a string that is not a valid RFC 6901 JSON Pointer (e.g. no leading slash or an unescaped `/`/`~` in the segment).
Common situations: Developers hit this after refactoring `workspace_path` or `escape_pointer_segment` (e.g. removing the leading `/`, dropping the escaping, or using a raw workspace name instead of a UUID in the pointer). It is not triggered by workspace data or environment — it is a code-invariant assertion.
Related errors
- Scratch path should be valid
- Pending approvals path should be valid
- Approval path should be valid
- Default profiles v3 JSON is invalid
- request_id called for unsupported request variant
AI-assisted analysis of BloopAI/vibe-kanban@4deb7eca8f (2026-08-29).
Data as JSON: /api/errors/649b2b7728892854.
Report an issue: GitHub.