{"record":{"id":"6b0d9e8f63cc9fa8","repo":"xai-org/x-algorithm","slug":"not-implemented-to-thrift-for-filteredreason","errorCode":null,"errorMessage":"Not implemented: to_thrift for FilteredReason","messagePattern":"Not implemented: to_thrift for FilteredReason","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"visibility-filtering-client/models.rs","lineNumber":372,"sourceCode":"                    proto.read_bool().unwrap();\n                    result = FilteredReason::TweetIsNullcast;\n                }\n                Some(16) => {\n                    proto.read_bool().unwrap();\n                    result = FilteredReason::ExclusiveTweet;\n                }\n                _ => {\n                    proto.skip(field.field_type).unwrap();\n                }\n            }\n            proto.read_field_end().unwrap();\n        }\n        proto.read_struct_end().unwrap();\n        result\n    }\n\n    fn to_thrift(&self, _proto: &mut dyn TOutputProtocol) {\n        panic!(\"Not implemented: to_thrift for FilteredReason\")\n    }\n}\n\nimpl From<vf_pb::KeywordMatch> for KeywordMatch {\n    fn from(value: vf_pb::KeywordMatch) -> Self {\n        KeywordMatch {\n            keyword: value.keyword,\n        }\n    }\n}\n\nimpl From<KeywordMatch> for vf_pb::KeywordMatch {\n    fn from(value: KeywordMatch) -> Self {\n        vf_pb::KeywordMatch {\n            keyword: value.keyword,\n        }\n    }\n}","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/visibility-filtering-client/models.rs#L354-L390","documentation":"FilteredReason's MValCodec impl decodes Thrift but panics on to_thrift, marking it as decode-only. The panic is an explicit design statement, not a runtime failure of external systems.","triggerScenarios":"Serializing FilteredReason via MValCodec::to_thrift — outbound RPC payloads, mval persistence, or symmetric round-trip tests.","commonSituations":"New producers of FilteredReason; generic encoders that walk all codec impls; codec conformance test suites.","solutions":["Do not encode FilteredReason.","Implement to_thrift mirroring the field ids/order the from_thrift reader uses (the reader builds `result` field by field).","Prefer the vf_pb protobuf conversion for any required serialization."],"exampleFix":"// before\nfn to_thrift(&self, _proto: &mut dyn TOutputProtocol) {\n    panic!(\"Not implemented: to_thrift for FilteredReason\")\n}\n\n// after\nfn to_thrift(&self, proto: &mut dyn TOutputProtocol) {\n    proto.write_struct_begin(&TStructIdentifier::new(\"FilteredReason\")).unwrap();\n    /* write each field with the same ids as the decoder */\n    proto.write_field_stop().unwrap();\n    proto.write_struct_end().unwrap();\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"trait WriteCodec { fn to_thrift(&self, p: &mut dyn TOutputProtocol); }\nfn encode<T: WriteCodec>(v: &T, p: &mut dyn TOutputProtocol) { v.to_thrift(p); }\n// FilteredReason excluded -> compile-time safety","tryCatchPattern":"if std::panic::catch_unwind(|| fr.to_thrift(proto)).is_err() { /* serialize vf_pb equivalent */ }","preventionTips":["Directional codec traits; ban 'encode all MValCodec' helpers.","Codec conformance tests should enumerate expected encodable types explicitly."],"tags":["rust","thrift","serialization","codec","visibility-filtering","not-implemented"],"backgroundTag":"thrift-unimplemented-serializer","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}