ruvnet/RuView · error

serialize: {e}

Error message

serialize: {e}

What it means

serde_json::to_string_pretty failed while serializing EnrollmentData (room_id, baseline_id, fs_hz, anchors, session) at the end of enroll. EnrollmentData is plain JSON-safe data (strings, f32, Vec, derived Serialize), so this is a defensive guard that in practice only triggers if a nested custom Serialize impl errors or the schema is changed to something JSON-unsafe.

Source

Thrown at v2/crates/wifi-densepose-cli/src/room.rs:206

        if !accepted {
            eprintln!("[enroll]   moving on without '{}'", label.as_str());
        }
    }

    if session.is_complete() {
        session.apply(EnrollmentEvent::Completed { at: now_unix() });
    }
    let (got, total) = session.progress();
    let data = EnrollmentData {
        room_id: args.room_id.clone(),
        baseline_id,
        fs_hz: args.fs_hz,
        anchors: features,
        session,
    };
    std::fs::write(
        &args.output,
        serde_json::to_string_pretty(&data).map_err(|e| anyhow::anyhow!("serialize: {e}"))?,
    )
    .map_err(|e| anyhow::anyhow!("cannot write {}: {e}", args.output))?;
    eprintln!(
        "\n[enroll] done: {got}/{total} anchors accepted → {} (next: `train-room`)",
        args.output
    );
    Ok(())
}

// ---------------------------------------------------------------------------
// train-room
// ---------------------------------------------------------------------------

/// Arguments for `train-room`.
#[derive(Args, Debug, Clone)]
pub struct TrainRoomArgs {
    /// Enrollment file from `enroll`.
    #[arg(long, default_value = "./enrollment.json")]

View on GitHub (pinned to 4685618388)

Solutions

  1. Treat it as a bug: identify which field's Serialize impl failed from the {e} payload
  2. If you modified the enrollment structs, add a unit test asserting to_string_pretty succeeds on sample data
  3. Re-run the enrollment — the features were in-memory only and are lost if the process exits
Defensive patterns

Strategy: try-catch

Try / catch

let json = serde_json::to_string_pretty(&data)
    .map_err(|e| anyhow::anyhow!("serialize: {e}"))?;
// Not pre-validatable: treat any failure as a schema bug and unit-test
// EnrollmentData serialization whenever its structs change.

Prevention

When it happens

Trigger: Effectively unreachable with the current structs; would require a modified AnchorFeature/EnrollmentSession Serialize impl returning an error (e.g. non-string map keys or a manually failing serializer introduced later).

Common situations: Almost never seen in the field; appears mainly in error catalogues as a low-probability guard around an infallible call.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/a8cc8256341520e9. Report an issue: GitHub.