{"record":{"id":"473f009235e2e9a1","repo":"cube-js/cube","slug":"write-variables-is-not-implemented-for-custom-prot","errorCode":null,"errorMessage":"write_variables is not implemented for custom protocol: {:?}","messagePattern":"write_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":96,"sourceCode":"                .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\n            ),\n        }\n    }\n\n    // TODO: Read without copy by holding acquired lock\n    pub fn all_variables(&self, protocol: DatabaseProtocol) -> DatabaseVariables {\n        self.read_variables(protocol).clone()\n    }\n\n    pub fn set_variables(&self, variables: DatabaseVariablesToUpdate, protocol: DatabaseProtocol) {\n        let mut current = self.write_variables(protocol.clone());\n\n        for new_var in variables.into_iter() {\n            if let Some(current_var_value) = current.get(&new_var.name) {\n                if !current_var_value.readonly {\n                    current.insert(new_var.name.clone(), new_var);","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubesql/cubesql/src/sql/server_manager.rs#L78-L114","documentation":"The write-side counterpart of read_variables: SET-style updates to database variables are only implemented for PostgreSQL connections. For a custom Extension protocol, write_variables panics via unimplemented! instead of applying the change.","triggerScenarios":"Calling set_variables on a session whose protocol is DatabaseProtocol::Extension(ext) — e.g. a client connected via a custom extension protocol issuing SET statements.","commonSituations":"Custom protocol clients sending SET / RESET commands; middleware that applies session variable changes without checking whether the protocol supports variable writes.","solutions":["Skip variable writes for extension protocols (no-op or protocol-specific handling)","Add a per-protocol variables map in ServerManager so extensions can store settings","Handle SET commands inside the extension's own command handler before reaching server_manager","Patch server_manager.rs:96 to persist extension variables like the Postgres path does"],"exampleFix":"// before\nDatabaseProtocol::Extension(ext) => unimplemented!(\"write_variables is not implemented for custom protocol: {:?}\", ext),\n// after\nDatabaseProtocol::Extension(_) => self.extension_variables.write().expect(\"failed to lock variables\"),","handlingStrategy":"type-guard","validationCode":"if matches!(protocol, DatabaseProtocol::PostgreSQL) { mgr.set_variables(...); } else { /* skip or route to extension */ }","typeGuard":"fn can_write_variables(p: &DatabaseProtocol) -> bool { matches!(p, DatabaseProtocol::PostgreSQL) }","tryCatchPattern":"let _ = std::panic::catch_unwind(|| mgr.set_variables(protocol.clone(), vars));\n// treat extension protocols as variable-less sessions","preventionTips":["Gate SET handling on protocol type in the session loop","Give extensions their own settings store so writes never reach the Postgres path","Mirror all ServerManager methods across protocols with tests","Log and no-op unsupported writes instead of unimplemented!"],"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"}