xai-org/x-algorithm · error
Not implemented: to_thrift for Action
Error message
Not implemented: to_thrift for Action
What it means
Action's MValCodec implementation is decode-only; calling to_thrift panics with an explicit 'not implemented' message. The type is meant to be read from Thrift responses, not written back.
Source
Thrown at visibility-filtering-client/models.rs:255
proto.read_field_end().unwrap();
}
proto.read_struct_end().unwrap();
if has_avoid {
result = Action::Avoid;
}
}
_ => {
proto.skip(field.field_type).unwrap();
}
}
proto.read_field_end().unwrap();
}
proto.read_struct_end().unwrap();
result
}
fn to_thrift(&self, _proto: &mut dyn TOutputProtocol) {
panic!("Not implemented: to_thrift for Action")
}
}
impl MValCodec for DropReason {
fn thrift_type() -> TType {
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();
}View on GitHub (pinned to 24c60942c5)
Solutions
- Do not serialize Action via this codec.
- Implement to_thrift by writing the same discriminators/tags the from_thrift reader consumes.
- Use the protobuf equivalent (vf_pb) if wire serialization is required.
Example fix
// before
fn to_thrift(&self, _proto: &mut dyn TOutputProtocol) {
panic!("Not implemented: to_thrift for Action")
}
// after
fn to_thrift(&self, proto: &mut dyn TOutputProtocol) {
// write the same tag/discriminator layout from_thrift parses
proto.write_struct_begin(&TStructIdentifier::new("Action")).unwrap();
/* field writes mirroring the reader */
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); }
// Action does not implement WriteCodec -> accidental encode fails at compile time Try / catch
let r = std::panic::catch_unwind(|| a.to_thrift(proto));
if r.is_err() { /* skip field or use protobuf representation */ } Prevention
- Split codec traits by direction.
- Review new outbound paths for Action usage before merge.
- Mark decode-only types in code review checklists.
When it happens
Trigger: Encoding an Action enum/struct via MValCodec::to_thrift — e.g. persisting it, sending it in a request, or a round-trip serialization test.
Common situations: Generic serializers that iterate all codec impls; new code forwarding Action values over Thrift; test utilities asserting encode/decode symmetry.
Related errors
- Not implemented: to_thrift for KeywordMatch
- Not implemented: to_thrift for SafetyResult
- Not implemented: to_thrift for DropReason
- 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/41035907e64b7a89.
Report an issue: GitHub.