BloopAI/vibe-kanban · critical
Execution process serialization should not fail
Error message
Execution process serialization should not fail
What it means
Panic raised by `Patch::add` when `serde_json::to_value(process)` fails to serialize an `ExecutionProcess`. Serde JSON serialization of a plain data struct cannot fail (no maps with non-string keys, no IO), so the library treats failure as an impossible invariant and panics via expect.
Source
Thrown at crates/services/src/services/events/patches.rs:30
/// Helper functions for creating execution process-specific patches
pub mod execution_process_patch {
use super::*;
fn execution_process_path(process_id: Uuid) -> String {
format!(
"/execution_processes/{}",
escape_pointer_segment(&process_id.to_string())
)
}
/// Create patch for adding a new execution process
pub fn add(process: &ExecutionProcess) -> Patch {
Patch(vec![PatchOperation::Add(AddOperation {
path: execution_process_path(process.id)
.try_into()
.expect("Execution process path should be valid"),
value: serde_json::to_value(process)
.expect("Execution process serialization should not fail"),
})])
}
/// Create patch for updating an existing execution process
pub fn replace(process: &ExecutionProcess) -> Patch {
Patch(vec![PatchOperation::Replace(ReplaceOperation {
path: execution_process_path(process.id)
.try_into()
.expect("Execution process path should be valid"),
value: serde_json::to_value(process)
.expect("Execution process serialization should not fail"),
})])
}
/// Create patch for removing an execution process
pub fn remove(process_id: Uuid) -> Patch {
Patch(vec![PatchOperation::Remove(RemoveOperation {
path: execution_process_path(process_id)View on GitHub (pinned to 4deb7eca8f)
Solutions
- Inspect ExecutionProcess (crates/db/src/models/execution_process.rs) for custom serialize_with/serde_with attributes or manual Serialize impls that can return Err; remove or fix them.
- Ensure no field serializes into a serde_json::Value::Object with non-string keys (e.g. HashMap<i64, _>).
- If failure must be tolerated, replace the expect with a match on to_value and return a Result or fall back to Value::Null.
- Run `cargo test -p db` round-trip tests (serialize then deserialize an ExecutionProcess) to catch the failing field.
Example fix
// before
value: serde_json::to_value(process).expect("Execution process serialization should not fail"),
// after
value: serde_json::to_value(process).unwrap_or(serde_json::Value::Null), // or propagate Result Defensive patterns
Strategy: validation
Validate before calling
// Pre-check that the struct round-trips through serde_json:
let v = serde_json::to_value(&process).expect("probe serialization");
let _back: ExecutionProcess = serde_json::from_value(v).expect("round-trip failed"); Type guard
fn is_json_serializable<T: serde::Serialize>(v: &T) -> bool {
serde_json::to_value(v).is_ok()
} Try / catch
// Panics are not catchable in normal Rust; validate first or use catch_unwind for belt-and-braces: let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| execution_process_patch::add(&process)));
Prevention
- Add a round-trip (to_value + from_value) unit test for ExecutionProcess in CI.
- Avoid fallible custom serialize_with on DB model structs; keep them plain data.
- Never use map fields with non-string keys in serde-serializable models.
- Review serde/serde_json upgrade diffs for behavior changes.
When it happens
Trigger: Calling `execution_process_patch::add(&process)` where the ExecutionProcess model contains a serde serializer that errors — e.g. a custom `#[serde(serialize_with)]` returning Err, a field serialized to a Map with non-string keys, or a poisoned/failed serialization adapter introduced by schema changes.
Common situations: Adding a custom Serialize impl or serde_with attribute to ExecutionProcess that can fail; upgrading serde_json and relying on an error path that previously never ran; generating the struct's TS/serde derives from a macro emitting an invalid serializer.
Related errors
- Workspace serialization should not fail
- Scratch serialization should not fail
- Default profiles v3 JSON is invalid
- Execution process path should be valid
- Scratch path should be valid
AI-assisted analysis of BloopAI/vibe-kanban@4deb7eca8f (2026-08-29).
Data as JSON: /api/errors/65e972122daaa4c6.
Report an issue: GitHub.