{"record":{"id":"2fec92f4ee21940d","repo":"t8y2/dbx","slug":"agentsessionid-is-required-2fec92","errorCode":null,"errorMessage":"agentSessionId is required","messagePattern":"agentSessionId is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/etcd2-go/main.go","lineNumber":176,"sourceCode":"\t}\n\tif len(req.ID) == 0 {\n\t\treq.ID = json.RawMessage(\"1\")\n\t}\n\tresult, shutdown, err := r.dispatch(req.Method, req.Params)\n\tif err != nil {\n\t\treturn errorResponse(req.ID, req.Method, stringParam(req.Params, \"agentSessionId\"), err), false\n\t}\n\treturn response{JSONRPC: \"2.0\", ID: req.ID, Result: result}, shutdown\n}\n\nfunc (r *runtimeServer) dispatch(method string, params map[string]json.RawMessage) (any, bool, error) {\n\tswitch method {\n\tcase \"handshake\":\n\t\treturn handshakeResult(), false, nil\n\tcase \"open_session\":\n\t\tid := requiredSessionID(params)\n\t\tif id == \"\" {\n\t\t\treturn nil, false, errors.New(\"agentSessionId is required\")\n\t\t}\n\t\treturn r.openSession(id, params)\n\tcase \"close_session\":\n\t\treturn r.closeSession(stringParam(params, \"agentSessionId\")), false, nil\n\tcase \"validate_session\":\n\t\tsession, err := r.session(requiredSessionID(params))\n\t\tif err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\tsession.mu.Lock()\n\t\tdefer session.mu.Unlock()\n\t\tresult, err := session.state.validateConnection()\n\t\treturn result, false, err\n\tcase \"cancel_session\":\n\t\tsession, err := r.session(requiredSessionID(params))\n\t\tif err != nil {\n\t\t\treturn nil, false, err\n\t\t}","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/etcd2-go/main.go#L158-L194","documentation":"dispatch routes JSON-RPC style methods for the etcd2 agent. open_session requires an agentSessionId to identify the session being created; when requiredSessionID(params) returns an empty string, dispatch fails with this error before any session is opened. Sessions drive subsequent per-key operations, so the ID is mandatory.","triggerScenarios":"Calling the open_session method without agentSessionId in params, with agentSessionId: null, or with an empty string value.","commonSituations":"A client handshake/transport layer that forgets to propagate the session ID generated by the caller; generating the ID asynchronously and dispatching before it is set; a config file or env template where the session-id field was left blank.","solutions":["Pass a non-empty agentSessionId string in the open_session params.","Generate a stable session identifier (e.g., UUID) client-side before dispatching open_session.","Validate the ID at the transport layer so empty IDs never reach dispatch.","Check that your client wrapper copies agentSessionId from the handshake result into subsequent calls."],"exampleFix":"// before\nres, err := client.Call(ctx, \"open_session\", map[string]any{})\n// after\nsessionID := uuid.NewString()\nres, err := client.Call(ctx, \"open_session\", map[string]any{\"agentSessionId\": sessionID})","handlingStrategy":"validation","validationCode":"id, _ := params[\"agentSessionId\"].(string)\nif id == \"\" {\n    return errors.New(\"generate a session id before calling open_session\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := client.Call(ctx, \"open_session\", params); err != nil && strings.Contains(err.Error(), \"agentSessionId is required\") {\n    // create/regenerate the session id and re-dispatch\n}","preventionTips":["Generate a UUID session id client-side before dispatching open_session","Validate the id is a non-empty string at the transport layer","Verify your client wrapper propagates the handshake/session id into open_session","Avoid async flows where open_session can fire before the id is assigned"],"tags":["etcd","validation","missing-parameter","session"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}