{"record":{"id":"a9dc47891379ef03","repo":"JuliusBrussee/caveman","slug":"native-runtime-unknown-event-q","errorCode":null,"errorMessage":"native runtime: unknown event %q","messagePattern":"native runtime: unknown event %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/nativeruntime/runtime.go","lineNumber":215,"sourceCode":"\t\treturn profile, profileFeatures{taskContract: true, compactState: true}, nil\n\tcase \"full-safe\", \"full-max\":\n\t\treturn profile, profileFeatures{taskContract: true, compactState: true, reuse: true, capture: true, mask: true, repository: true}, nil\n\tdefault:\n\t\treturn \"\", profileFeatures{}, fmt.Errorf(\"native runtime: unknown profile %q\", raw)\n\t}\n}\n\nfunc (r *Runtime) Handle(_ context.Context, request Request) (Response, error) {\n\tstarted := time.Now()\n\tsessionLock := r.sessionLock(request.Session.ID)\n\tsessionLock.Lock()\n\tdefer sessionLock.Unlock()\n\n\tif request.ProtocolVersion != ProtocolVersion {\n\t\treturn Response{}, fmt.Errorf(\"native runtime: unsupported protocol version %d\", request.ProtocolVersion)\n\t}\n\tif _, ok := eventTypes[request.Event.Type]; !ok {\n\t\treturn Response{}, fmt.Errorf(\"native runtime: unknown event %q\", request.Event.Type)\n\t}\n\tif strings.TrimSpace(request.Session.ID) == \"\" {\n\t\treturn Response{}, errors.New(\"native runtime: session id is required\")\n\t}\n\tpolicyMode := request.PolicyMode\n\tif policyMode == \"\" {\n\t\tpolicyMode = \"safe\"\n\t}\n\tif policyMode != \"record\" && policyMode != \"safe\" && policyMode != \"max\" {\n\t\treturn Response{}, fmt.Errorf(\"native runtime: unknown policy mode %q\", policyMode)\n\t}\n\trequest.PolicyMode = policyMode\n\tprofile, features, err := resolveProfile(request.Profile, policyMode)\n\tif err != nil {\n\t\treturn Response{}, err\n\t}\n\trequest.Profile = profile\n\tr.mu.Lock()","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/nativeruntime/runtime.go#L197-L233","documentation":"The native runtime's Handle method validates that the incoming request's event type is one of the known event types before processing it. If request.Event.Type is not registered in the eventTypes set, Handle refuses the request with this error. This guards the runtime IPC protocol against malformed or stale clients sending unrecognized events.","triggerScenarios":"Calling Handle with a request whose Event.Type is not a key of eventTypes (e.g. a typo like \"sesion_end\", an event added in a newer client but unknown to an older runtime, or a client built against a different protocol).","commonSituations":"Version skew between the coding agent/proxy client and the runtime binary; hand-crafted JSON sent over the unix socket; typos in event names; tests or scripts that invent event names.","solutions":["Check the event type string for typos against the eventTypes map keys in proxy/internal/nativeruntime/runtime.go","Rebuild/restart both client and runtime so protocol versions and event sets match","If the event is legitimately new, register it in eventTypes and add its handling case"],"exampleFix":"// before\nresp, err := rt.Handle(ctx, Request{Event: Event{Type: \"session-close\"}})\n// after\nresp, err := rt.Handle(ctx, Request{Event: Event{Type: \"session_end\"}})","handlingStrategy":"validation","validationCode":"var knownEvents = map[string]bool{\"session_start\": true, \"session_end\": true}\nif !knownEvents[req.Event.Type] {\n\treturn fmt.Errorf(\"unsupported event %q\", req.Event.Type)\n}","typeGuard":"func isKnownEvent(t string) bool { _, ok := eventTypes[t]; return ok }","tryCatchPattern":null,"preventionTips":["Keep a shared constants file of event type strings on both client and server","Pin client and runtime versions together; check protocol version first","Log the full request when this error occurs to spot typos early"],"tags":["validation","protocol","unknown-event"],"backgroundTag":"invalid-enum-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}