{"record":{"id":"b1b112401a89f6e4","repo":"t8y2/dbx","slug":"agentsessionid-is-required-b1b112","errorCode":null,"errorMessage":"agentSessionId is required","messagePattern":"agentSessionId is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/xugu/main.go","lineNumber":786,"sourceCode":"\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 map[string]any{\n\t\t\t\"protocolVersion\":      multiSessionProtocolVersion,\n\t\t\t\"agentProtocolVersion\": multiSessionProtocolVersion,\n\t\t\t\"capabilities\":         []string{\"connect\", \"test_connection\", \"metadata\", \"query\", \"ddl\", \"structured_error_v1\", \"multi_session\"},\n\t\t}, false, nil\n\tcase \"open_session\":\n\t\tagentSessionID := stringParam(params, \"agentSessionId\")\n\t\tif agentSessionID == \"\" {\n\t\t\treturn nil, false, errors.New(\"agentSessionId is required\")\n\t\t}\n\t\tvar cp connectParams\n\t\tif err := decodeParams(params, &cp); err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\treturn map[string]bool{\"ok\": true}, false, r.openSession(agentSessionID, cp)\n\tcase \"close_session\":\n\t\treturn map[string]bool{\"ok\": true}, false, r.closeSession(stringParam(params, \"agentSessionId\"))\n\tcase \"validate_session\":\n\t\tagentSessionID := stringParam(params, \"agentSessionId\")\n\t\tsession, err := r.session(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\tif err := session.server.validateConnection(); err == nil {\n\t\t\treturn map[string]bool{\"ok\": true}, false, nil","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/xugu/main.go#L768-L804","documentation":"The xugu agent's open_session RPC handler requires the agentSessionId parameter and returns this error when it is missing or empty (stringParam trims/returns empty). Without a session ID the agent cannot register the multi-session connection.","triggerScenarios":"Calling the open_session RPC without params[\"agentSessionId\"], or with an empty/whitespace value; a client using structured_error/multi_session capabilities but omitting the session ID field.","commonSituations":"Older client versions that predate the multi_session protocol sending open_session without the field; a serialization bug dropping the parameter; manual RPC testing against the agent.","solutions":["Include a non-empty agentSessionId in the open_session params","Upgrade the client to the protocol version advertising multi_session so the field is always set","Check decodeParams/param marshalling on the client if the field is present but arrives empty"],"exampleFix":"// before\nparams := map[string]any{\"connectParams\": cp}\n// after\nparams := map[string]any{\"agentSessionId\": sessionID, \"connectParams\": cp}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(agentSessionID) == \"\" { return errors.New(\"agentSessionId is required\") }","typeGuard":"func hasSessionID(params map[string]any) bool { s, _ := params[\"agentSessionId\"].(string); return strings.TrimSpace(s) != \"\" }","tryCatchPattern":"resp, err := agent.RPC(ctx, \"open_session\", params)\nif err != nil && strings.Contains(err.Error(), \"agentSessionId is required\") { return ErrSessionIDMissing }","preventionTips":["Always generate and attach agentSessionId in open_session params","Keep client protocol version aligned with multi_session capability","Unit-test param marshalling for required fields"],"tags":["validation","parameters","multi-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"}