{"record":{"id":"04b5c33c54f29e1c","repo":"t8y2/dbx","slug":"agentsessionid-is-required-04b5c3","errorCode":null,"errorMessage":"agentSessionId is required","messagePattern":"agentSessionId is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/iotdb/main.go","lineNumber":186,"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(true), false, nil\n\tcase \"open_session\":\n\t\tid := stringParam(params, \"agentSessionId\")\n\t\tif id == \"\" {\n\t\t\treturn nil, false, errors.New(\"agentSessionId is required\")\n\t\t}\n\t\tvar connection connectParams\n\t\tif err := decodeParams(params, &connection); err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\treturn map[string]bool{\"ok\": true}, false, r.openSession(id, connection)\n\tcase \"close_session\":\n\t\treturn map[string]bool{\"ok\": true}, false, r.closeSession(stringParam(params, \"agentSessionId\"))\n\tcase \"validate_session\":\n\t\tsession, err := r.session(stringParam(params, \"agentSessionId\"))\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\treturn map[string]bool{\"ok\": true}, false, session.server.validateConnection()\n\tcase \"cancel_session\":\n\t\tsession, err := r.session(stringParam(params, \"agentSessionId\"))","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/iotdb/main.go#L168-L204","documentation":"The IoTDB driver's dispatch handler for the open_session method requires an agentSessionId parameter. An empty value means the caller cannot be associated with a session, so the request is rejected before any connection is opened.","triggerScenarios":"Calling open_session via the driver's RPC/dispatch surface without providing agentSessionId, or providing it as an empty string.","commonSituations":"Client SDK omitting a required field after a protocol update; hand-rolled JSON-RPC requests missing the parameter; session ID variable uninitialized on the caller side.","solutions":["Pass a non-empty agentSessionId parameter in the open_session request params.","Check the client library version matches the driver protocol so the session ID is populated automatically.","If IDs are caller-generated, generate a stable unique ID (e.g. UUID) before calling open_session."],"exampleFix":"// before\n{\"method\":\"open_session\",\"params\":{}}\n// after\n{\"method\":\"open_session\",\"params\":{\"agentSessionId\":\"6f1c...\"}}","handlingStrategy":"validation","validationCode":"if agentSessionID == \"\" {\n\treturn errors.New(\"generate agentSessionId before calling open_session\")\n}","typeGuard":"func hasAgentSessionID(params map[string]any) bool {\n\tid, _ := params[\"agentSessionId\"].(string)\n\treturn id != \"\"\n}","tryCatchPattern":"ok, _, err := dispatch(\"open_session\", params)\nif err != nil {\n\tif strings.Contains(err.Error(), \"agentSessionId is required\") {\n\t\tparams[\"agentSessionId\"] = uuid.NewString()\n\t\tok, _, err = dispatch(\"open_session\", params)\n\t}\n\tif err != nil { return err }\n}\n_ = ok","preventionTips":["Generate a UUID session ID in the client constructor so it is always present.","Validate request params against the driver's schema before dispatch.","Keep client SDK versions in sync with driver protocol changes."],"tags":["iotdb","rpc","session","validation"],"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"}