Skip to content

bug: nil UUID fallback for agentId causes silent event loss #23

Description

@beonde

Problem

In GuardEventEmitter.emit_policy_enforced(), when _resolve_agent_id() returns None, the code falls back to str(uuid.UUID(int=0)) (all-zeros UUID 00000000-0000-0000-0000-000000000000).

However, the server's IngestEvent handler explicitly rejects nil UUIDs:

if req.AgentID == uuid.Nil {
    response.BadRequest(w, "agentId is required")
    return
}

This means events are silently dropped whenever agent resolution fails. The logger.warning on the 400 response surfaces the symptom, but the telemetry data is permanently lost.

Where

capiscio_mcp/events.pyemit_policy_enforced() method, line:

event: Dict[str, Any] = {
    ...
    "agentId": effective_agent_id or str(uuid.UUID(int=0)),
    ...
}

Suggested fix

Either:

  1. Skip emission entirely when no valid agentId can be resolved — log a warning and return early
  2. Require a valid agent_id at GuardEventEmitter construction time (fail loudly at setup, not silently per-event)

Option 1 is simpler and maintains the best-effort contract. Option 2 is stricter but catches misconfiguration early.

Context

Introduced on feat/guard-event-emission branch as part of the event payload restructuring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions