{"record":{"id":"c4539e0e40f6462f","repo":"t8y2/dbx","slug":"agentsessionid-is-required-c4539e","errorCode":null,"errorMessage":"agentSessionId is required","messagePattern":"agentSessionId is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/vastbase-go/main.go","lineNumber":240,"sourceCode":"\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\":      protocolVersion,\n\t\t\t\"agentProtocolVersion\": protocolVersion,\n\t\t\t\"capabilities\": []string{\n\t\t\t\t\"connect\", \"test_connection\", \"metadata\", \"query\", \"paged_query\", \"transaction\", \"ddl\", \"multi_session\", \"structured_error_v1\",\n\t\t\t},\n\t\t}, 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 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(id, 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\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\trelease, permitErr := session.server.acquireOperationPermit(\"validate_session\")\n\t\tif permitErr != nil {\n\t\t\treturn nil, false, permitErr","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/vastbase-go/main.go#L222-L258","documentation":"The vastbase-go driver's open_session operation creates a named session keyed by agentSessionId. This identifier is required to route subsequent operations (query, transaction, etc.) to that session, so the driver throws when it is missing or empty.","triggerScenarios":"Dispatching open_session without agentSessionId, or with agentSessionId:\"\"; constructing params programmatically where the id variable was empty.","commonSituations":"Forgetting the session id when switching from simple query ops to multi-session usage; string interpolation of an unset variable; orchestrators generating session ids that end up empty on first run.","solutions":["Generate and pass a non-empty agentSessionId, e.g. a UUID","Reuse the same agentSessionId in later operations targeting the session","Validate the id before dispatching open_session"],"exampleFix":"// before\n{ \"op\": \"open_session\", \"connect\": { \"dsn\": \"vb://localhost/db\" } }\n// after\n{ \"op\": \"open_session\", \"agentSessionId\": \"sess-1\", \"connect\": { \"dsn\": \"vb://localhost/db\" } }","handlingStrategy":"validation","validationCode":"const id = String(crypto.randomUUID());\nif (!id) throw new Error(\"agentSessionId is required\");\nawait agent.dispatch(\"open_session\", { agentSessionId: id, ...connectParams });","typeGuard":"function hasSessionId(p) { return typeof p.agentSessionId === \"string\" && p.agentSessionId.trim().length > 0; }","tryCatchPattern":"try { await agent.dispatch(\"open_session\", params); } catch (e) { if (/agentSessionId is required/.test(e.message)) { params.agentSessionId = crypto.randomUUID(); await agent.dispatch(\"open_session\", params); } else throw e; }","preventionTips":["Generate a session id before open_session and store it","Reuse the same id for session-scoped operations","Validate required keys in a dispatch wrapper"],"tags":["vastbase","parameter-validation","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"}