{"record":{"id":"7873f79a50ac5ffa","repo":"t8y2/dbx","slug":"not-connected-call-connect-first-7873f7","errorCode":null,"errorMessage":"Not connected. Call connect first.","messagePattern":"Not connected\\. Call connect first\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/helpers.go","lineNumber":322,"sourceCode":"\nfunc connectionObject(params jsonObject) jsonObject {\n\tif connection := objectOrNil(params, \"connection\"); connection != nil {\n\t\treturn connection\n\t}\n\treturn params\n}\n\nfunc (s *server) currentConnectionConfig(params jsonObject) jsonObject {\n\tif connection := objectOrNil(params, \"connection\"); connection != nil {\n\t\treturn connection\n\t}\n\treturn s.cachedConnection\n}\n\nfunc (s *server) requireConnectionConfig(params jsonObject) (jsonObject, error) {\n\tconnection := s.currentConnectionConfig(params)\n\tif connection == nil {\n\t\treturn nil, errors.New(\"Not connected. Call connect first.\")\n\t}\n\treturn connection, nil\n}\n\nfunc (s *server) requireConnection() (*amqp.Connection, error) {\n\tif s.connection == nil {\n\t\treturn nil, errors.New(\"Not connected. Call connect first.\")\n\t}\n\treturn s.connection, nil\n}\n\nfunc queueName(params jsonObject) (string, error) {\n\tname := stringOrEmpty(params, \"topic\")\n\tif strings.TrimSpace(name) == \"\" {\n\t\tname = stringOrEmpty(params, \"name\")\n\t}\n\tif strings.TrimSpace(name) == \"\" {\n\t\treturn \"\", errors.New(\"topic (queue name) is required\")","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/helpers.go#L304-L340","documentation":"requireConnectionConfig retrieves the connection configuration cached by a prior connect call (via currentConnectionConfig). The rabbitmq helper handlers require an established connection config before serving operations; without one they return this error. It is a state-machine precondition, not a network failure.","triggerScenarios":"Invoking listTopics, listConsumers, listNamespaces, createNamespace, deleteNamespace, or listExchanges before a successful connect call, or after connect failed / state was reset so currentConnectionConfig returns nil.","commonSituations":"Server restart discarding cached connection state while a client keeps issuing calls; connect call failing silently client-side; calling management operations from a fresh session that never ran connect.","solutions":["Call connect with valid broker connection params first, verify it succeeds, then invoke the management operations.","Handle the error client-side by automatically re-running connect before retrying the operation.","Check why the cached config was lost (server restart, failed connect) and make the client reconnect on session loss."],"exampleFix":"// before\ntopics, err := server.Call(\"listTopics\", nil) // fails: not connected\n// after\nif _, err := server.Call(\"connect\", connectParams); err != nil {\n    return err\n}\ntopics, err := server.Call(\"listTopics\", nil)","handlingStrategy":"validation","validationCode":"if server.CurrentConnectionConfig() == nil {\n    if err := server.Connect(connectParams); err != nil {\n        return err\n    }\n}","typeGuard":null,"tryCatchPattern":"topics, err := server.Call(\"listTopics\", nil)\nif err != nil && strings.Contains(err.Error(), \"Not connected\") {\n    if cerr := server.Connect(connectParams); cerr != nil {\n        return cerr\n    }\n    topics, err = server.Call(\"listTopics\", nil)\n}","preventionTips":["Always call connect first in every session before management operations.","Auto-reconnect on session restore after server restart.","Track connection state client-side and gate operations on it.","Fail connect loudly — a silently failed connect surfaces later as this error."],"tags":["connection","state","rabbitmq"],"backgroundTag":"not-connected","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"}