{"record":{"id":"e24439b82edcaadd","repo":"cube-js/cube","slug":"read-variables-is-not-implemented-for-custom-proto","errorCode":null,"errorMessage":"read_variables is not implemented for custom protocol: {:?}","messagePattern":"read_variables is not implemented for custom protocol: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cubesql/cubesql/src/sql/server_manager.rs","lineNumber":80,"sourceCode":"            pg_auth,\n            compiler_cache,\n            nonce,\n            config_obj,\n            configuration: ServerConfiguration::default(),\n            postgres_variables: RwLockSync::new(postgres_default_global_variables()),\n        }\n    }\n\n    pub fn read_variables(\n        &self,\n        protocol: DatabaseProtocol,\n    ) -> RwLockReadGuard<'_, DatabaseVariables> {\n        match protocol {\n            DatabaseProtocol::PostgreSQL => self\n                .postgres_variables\n                .read()\n                .expect(\"failed to unlock variables for reading\"),\n            DatabaseProtocol::Extension(ext) => unimplemented!(\n                \"read_variables is not implemented for custom protocol: {:?}\",\n                ext\n            ),\n        }\n    }\n\n    fn write_variables(\n        &self,\n        protocol: DatabaseProtocol,\n    ) -> RwLockWriteGuard<'_, DatabaseVariables> {\n        match protocol {\n            DatabaseProtocol::PostgreSQL => self\n                .postgres_variables\n                .write()\n                .expect(\"failed to unlock variables for reading\"),\n            DatabaseProtocol::Extension(ext) => unimplemented!(\n                \"write_variables is not implemented for custom protocol: {:?}\",\n                ext","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubesql/cubesql/src/sql/server_manager.rs#L62-L98","documentation":"ServerManager keeps session/database variables in a RwLock keyed by protocol. Only PostgreSQL has a variables store; when the connection uses a custom Extension protocol, read_variables panics because extension protocols have no variable storage.","triggerScenarios":"Calling all_variables (or anything that reads variables) on a session whose DatabaseProtocol is DatabaseProtocol::Extension(ext) — i.e. a custom/extension protocol connection that issues a SHOW or variables query.","commonSituations":"Implementing a custom CubeSQL extension protocol and a client sends SHOW/SET-style commands; protocol handlers that unconditionally query variables without checking protocol type first.","solutions":["Guard the call: only read variables when protocol is PostgreSQL; return empty variables for extensions","Initialize a per-extension variables store in ServerManager for the extension protocol","Route the variables request to the extension's own handler instead of server_manager.read_variables","Patch server_manager.rs:80 to return a default empty DatabaseVariables for Extension"],"exampleFix":"// before\nDatabaseProtocol::Extension(ext) => unimplemented!(\"read_variables is not implemented for custom protocol: {:?}\", ext),\n// after\nDatabaseProtocol::Extension(_) => self.extension_variables.read().expect(\"failed to lock variables\"),","handlingStrategy":"type-guard","validationCode":"fn supports_variables(protocol: &DatabaseProtocol) -> bool {\n    matches!(protocol, DatabaseProtocol::PostgreSQL)\n}\nif supports_variables(&session.protocol()) { vars = mgr.all_variables(...); }","typeGuard":"fn is_postgres(p: &DatabaseProtocol) -> bool { matches!(p, DatabaseProtocol::PostgreSQL) }","tryCatchPattern":"let vars = std::panic::catch_unwind(|| mgr.all_variables(protocol.clone()))\n    .map(|g| g.clone())\n    .unwrap_or_default(); // empty variables for extension protocols","preventionTips":["Check DatabaseProtocol before touching variable APIs","Implement extension-protocol variable storage up front when adding a custom protocol","Return empty/default variables for extensions instead of panicking","Add protocol-coverage tests for all ServerManager methods"],"tags":["rust","protocols","variables","unimplemented"],"backgroundTag":"protocol-not-supported","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}