t8y2/dbx · error

agentSessionId is required

Error message

agentSessionId is required

What it means

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.

Source

Thrown at agents/drivers/iotdb/main.go:186

	}
	if len(req.ID) == 0 {
		req.ID = json.RawMessage("1")
	}
	result, shutdown, err := r.dispatch(req.Method, req.Params)
	if err != nil {
		return errorResponse(req.ID, req.Method, stringParam(req.Params, "agentSessionId"), err), false
	}
	return response{JSONRPC: "2.0", ID: req.ID, Result: result}, shutdown
}

func (r *runtimeServer) dispatch(method string, params map[string]json.RawMessage) (any, bool, error) {
	switch method {
	case "handshake":
		return handshakeResult(true), false, nil
	case "open_session":
		id := stringParam(params, "agentSessionId")
		if id == "" {
			return nil, false, errors.New("agentSessionId is required")
		}
		var connection connectParams
		if err := decodeParams(params, &connection); err != nil {
			return nil, false, err
		}
		return map[string]bool{"ok": true}, false, r.openSession(id, connection)
	case "close_session":
		return map[string]bool{"ok": true}, false, r.closeSession(stringParam(params, "agentSessionId"))
	case "validate_session":
		session, err := r.session(stringParam(params, "agentSessionId"))
		if err != nil {
			return nil, false, err
		}
		session.mu.Lock()
		defer session.mu.Unlock()
		return map[string]bool{"ok": true}, false, session.server.validateConnection()
	case "cancel_session":
		session, err := r.session(stringParam(params, "agentSessionId"))

View on GitHub (pinned to c0390bff16)

Solutions

  1. Pass a non-empty agentSessionId parameter in the open_session request params.
  2. Check the client library version matches the driver protocol so the session ID is populated automatically.
  3. If IDs are caller-generated, generate a stable unique ID (e.g. UUID) before calling open_session.

Example fix

// before
{"method":"open_session","params":{}}
// after
{"method":"open_session","params":{"agentSessionId":"6f1c..."}}
Defensive patterns

Strategy: validation

Validate before calling

if agentSessionID == "" {
	return errors.New("generate agentSessionId before calling open_session")
}

Type guard

func hasAgentSessionID(params map[string]any) bool {
	id, _ := params["agentSessionId"].(string)
	return id != ""
}

Try / catch

ok, _, err := dispatch("open_session", params)
if err != nil {
	if strings.Contains(err.Error(), "agentSessionId is required") {
		params["agentSessionId"] = uuid.NewString()
		ok, _, err = dispatch("open_session", params)
	}
	if err != nil { return err }
}
_ = ok

Prevention

When it happens

Trigger: Calling open_session via the driver's RPC/dispatch surface without providing agentSessionId, or providing it as an empty string.

Common situations: 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.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/04b5c33c54f29e1c. Report an issue: GitHub.