{"record":{"id":"332ae069ef6b2ce0","repo":"tikv/tikv","slug":"it-s-not-a-titan-cf-option","errorCode":null,"errorMessage":"it's not a titan cf option","messagePattern":"it's not a titan cf option","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/engine_tirocks/src/cf_options.rs","lineNumber":45,"sourceCode":"\n    #[inline]\n    pub fn default_titan() -> Self {\n        RocksCfOptions(Options::Titan(Default::default()))\n    }\n\n    #[inline]\n    pub(crate) fn into_rocks(self) -> CfOptions {\n        match self.0 {\n            Options::Rocks(opt) => opt,\n            _ => panic!(\"it's a titan cf option\"),\n        }\n    }\n\n    #[inline]\n    pub(crate) fn into_titan(self) -> TitanCfOptions {\n        match self.0 {\n            Options::Titan(opt) => opt,\n            _ => panic!(\"it's not a titan cf option\"),\n        }\n    }\n}\n\nimpl Default for RocksCfOptions {\n    #[inline]\n    fn default() -> Self {\n        RocksCfOptions(Options::Rocks(Default::default()))\n    }\n}\n\nimpl Deref for RocksCfOptions {\n    type Target = RawCfOptions;\n\n    #[inline]\n    fn deref(&self) -> &Self::Target {\n        match &self.0 {\n            Options::Rocks(opt) => opt,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/tikv/tikv/blob/78aedc1c81ef3f7d8bacc6e9d09f56460f134937/components/engine_tirocks/src/cf_options.rs#L27-L63","documentation":"RocksCfOptions wraps an enum that is either plain RocksDB or Titan options; into_titan() panics when called on a variant constructed via default()/new() (plain RocksDB) rather than default_titan(). The faulty input is a RocksCfOptions holding Options::Rocks, i.e. a Titan-specific consumer received a non-Titan config object.","triggerScenarios":"Calling into_titan on options created via the RocksDB constructor (Options::Rocks) — e.g. Titan engine setup code handed Rocks-built CF options.","commonSituations":"Using default/new Rocks options builders inside titan-enabled engine construction; feature-flag code paths sharing one option builder across titan and non-titan engines.","solutions":["Build the options with the Titan constructor (Options::Titan) before calling into_titan.","Use into_rocks when the target is a plain RocksDB engine.","Add an explicit variant check/branch instead of unconditional unwrap at the call site."],"exampleFix":"// before\nlet titan_cf = RocksCfOptions::new_rocks().into_titan(); // panic\n// after\nlet titan_cf = RocksCfOptions::new_titan().into_titan();","handlingStrategy":"type-guard","validationCode":"fn expects_titan(opts: &RocksCfOptions) -> bool {\n    matches!(opts.as_ref(), Options::Titan(_))\n}\n// guard before into_titan\nif !expects_titan(&cf_opts) { /* construct Titan variant first */ }","typeGuard":"fn as_titan_cf(opts: &RocksCfOptions) -> Option<&titan::CfOptions> {\n    match &opts.0 { Options::Titan(o) => Some(o), _ => None }\n}","tryCatchPattern":null,"preventionTips":["When the titan feature is enabled, build CF options with the Titan constructor everywhere.","Add compile-time or unit-test assertions that titan engine paths never construct Options::Rocks.","Centralize engine option construction in one module so variant selection is explicit."],"tags":["tirocks","titan","type-mismatch","panic"],"backgroundTag":"engine-options-type-mismatch","analyzedSha":"78aedc1c81ef3f7d8bacc6e9d09f56460f134937","analyzedAt":"2026-09-03T23:31:32.398Z","contentChangedAt":"2026-09-03T23:31:32.398Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}