pbakaus/impeccable · error

serve-question: {}

Error message

serve-question: {}

What it means

The server state failed to load/validate the round payload (ServerState::load_round returned an error message). The command prints `serve-question: <msg>` and exits 1 before binding any port, meaning the payload did not parse or validate as a valid question round.

Source

Thrown at crates/context/src/serve_question.rs:409

    }

    // ---- server (blocking or detached) ----
    let raw = match &payload_path {
        Some(pp) => match std::fs::read(jsp::resolve(&cwd, &[pp])) {
            Ok(b) => String::from_utf8_lossy(&b).into_owned(),
            Err(e) => {
                io.err(&format!("Error: {}\n", crate::util::node_read_error(pp, &e)));
                return 1;
            }
        },
        None => io.stdin().to_string(),
    };
    let detached_key = if a.has("detached-serve") { a.arg("key") } else { None };
    let state = Arc::new(Mutex::new(ServerState::new(cwd.clone(), qdir.clone(), detached_key.clone(), idle_grace_ms)));
    {
        let mut st = state.lock().unwrap();
        if let Err(msg) = st.load_round(&raw) {
            io.err(&format!("serve-question: {}\n", msg));
            return 1;
        }
    }
    let port = if port_arg.is_finite() && port_arg >= 0.0 { port_arg as u16 } else { 0 };
    let server = match tiny_http::Server::http(("127.0.0.1", port)) {
        Ok(s) => s,
        Err(e) => {
            io.err(&format!("Error: listen EADDRINUSE: {}\n", e));
            return 1;
        }
    };
    let actual_port = server.server_addr().to_ip().map(|a| a.port()).unwrap_or(port);
    let url = format!("http://127.0.0.1:{}/", actual_port);
    if a.has("detached-serve") {
        let _ = std::fs::create_dir_all(&qdir);
        let key = a.arg("key").unwrap_or_default();
        let st = json!({ "pid": std::process::id(), "port": actual_port, "url": url });
        let _ = std::fs::write(state_file(&qdir, &key), json_compact(&st));

View on GitHub (pinned to 2bc2879276)

Solutions

  1. Read the printed <msg> for the specific field/format problem.
  2. Validate the payload is well-formed JSON (e.g. `jq . payload.json`).
  3. Regenerate the payload with the tool that produced it instead of editing by hand.
  4. Ensure stdin actually contains the payload when no --payload-path is given (not shell echo of an empty string).

Example fix

// before
echo "" | impeccable serve-question
// after
impeccable serve-question --payload-path ./question.json
Defensive patterns

Strategy: validation

Validate before calling

// validate the payload parses as JSON before serving
const payload = JSON.parse(fs.readFileSync(payloadPath, 'utf8'));
if (!payload || typeof payload !== 'object') throw new Error('invalid round payload');

Type guard

function isValidRoundPayload(p) {
  return typeof p === 'object' && p !== null && !Array.isArray(p) && typeof p.question === 'string';
}

Try / catch

try {
  run('impeccable serve-question --payload-path q.json');
} catch (e) {
  if (e.stderr.startsWith('serve-question:')) console.error('payload rejected:', e.stderr);
  throw e;
}

Prevention

When it happens

Trigger: `serve-question` is invoked with payload content (from --payload-path or stdin) that does not satisfy load_round: malformed JSON, missing required question fields, or a structurally invalid round document.

Common situations: Hand-edited or truncated payload files, piping the wrong content into stdin, an upstream tool emitting an unexpected payload schema, or reading an error page instead of the JSON payload.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of pbakaus/impeccable@2bc2879276 (2026-09-08). Data as JSON: /api/errors/27e69626603e731f. Report an issue: GitHub.