xai-org/x-algorithm · error
Not implemented: to_thrift for DropReason
Error message
Not implemented: to_thrift for DropReason
What it means
DropReason is an empty struct whose Thrift codec implements only decoding; to_thrift panics to mark serialization as unimplemented. It is a placeholder type read from visibility-filtering responses.
Source
Thrown at visibility-filtering-client/models.rs:279
TType::Struct
}
fn from_thrift(proto: &mut dyn TInputProtocol) -> Self {
proto.read_struct_begin().unwrap();
loop {
let field = proto.read_field_begin().unwrap();
if field.field_type == TType::Stop {
break;
}
proto.skip(field.field_type).unwrap();
proto.read_field_end().unwrap();
}
proto.read_struct_end().unwrap();
DropReason {}
}
fn to_thrift(&self, _proto: &mut dyn TOutputProtocol) {
panic!("Not implemented: to_thrift for DropReason")
}
}
impl MValCodec for FilteredReason {
fn thrift_type() -> TType {
TType::Struct
}
fn from_thrift(proto: &mut dyn TInputProtocol) -> Self {
proto.read_struct_begin().unwrap();
let mut result = FilteredReason::UnspecifiedReason;
loop {
let field = proto.read_field_begin().unwrap();
if field.field_type == TType::Stop {
break;
}
match field.id {
Some(1) => {View on GitHub (pinned to 24c60942c5)
Solutions
- Exclude DropReason from serialization; it carries no data.
- If encoding is required, implement to_thrift as an empty struct: write_struct_begin, write_field_stop, write_struct_end.
- Replace uses with the protobuf equivalent if it must cross a boundary.
Example fix
// before
fn to_thrift(&self, _proto: &mut dyn TOutputProtocol) {
panic!("Not implemented: to_thrift for DropReason")
}
// after (empty struct)
fn to_thrift(&self, proto: &mut dyn TOutputProtocol) {
proto.write_struct_begin(&TStructIdentifier::new("DropReason")).unwrap();
proto.write_field_stop().unwrap();
proto.write_struct_end().unwrap();
} Defensive patterns
Strategy: type-guard
Type guard
trait WriteCodec { fn to_thrift(&self, p: &mut dyn TOutputProtocol); }
// DropReason (empty struct) is not WriteCodec; encoders can't reach the panic Try / catch
if std::panic::catch_unwind(|| dr.to_thrift(proto)).is_err() { /* no data to serialize; skip */ } Prevention
- Use directional codec traits.
- Since DropReason is empty, prefer a unit/Option marker instead of serializing it.
- Keep generic encoders driven by an explicit allow-list of types.
When it happens
Trigger: Any attempt to write a DropReason value through MValCodec::to_thrift, including generic encode paths and round-trip tests.
Common situations: Generic serialization infrastructure that encodes all codec types; refactors that move DropReason into an outbound path.
Related errors
- Not implemented: to_thrift for KeywordMatch
- Not implemented: to_thrift for SafetyResult
- Not implemented: to_thrift for Action
- Not implemented: to_thrift for FilteredReason
- LookupContext should not be decoded from Thrift
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/74526087c81be89c.
Report an issue: GitHub.