File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/serializers/type_serializers Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,10 @@ use std::borrow::Cow;
88use crate :: build_tools:: py_schema_err;
99use crate :: common:: union:: { Discriminator , SMALL_UNION_THRESHOLD } ;
1010use crate :: definitions:: DefinitionsBuilder ;
11+ use crate :: errors:: write_truncated_to_50_bytes;
1112use crate :: lookup_key:: LookupKey ;
1213use crate :: serializers:: type_serializers:: py_err_se_err;
13- use crate :: tools:: SchemaDict ;
14+ use crate :: tools:: { safe_repr , SchemaDict } ;
1415use crate :: PydanticSerializationUnexpectedValue ;
1516
1617use super :: {
@@ -445,9 +446,15 @@ impl TaggedUnionSerializer {
445446 Discriminator :: Function ( func) => func. call1 ( py, ( value, ) ) . ok ( ) ,
446447 } ;
447448 if discriminator_value. is_none ( ) {
449+ let input_str = safe_repr ( value) ;
450+ let mut value_str = String :: with_capacity ( 100 ) ;
451+ value_str. push_str ( "with value `" ) ;
452+ write_truncated_to_50_bytes ( & mut value_str, input_str. to_cow ( ) ) . expect ( "Writing to a `String` failed" ) ;
453+ value_str. push ( '`' ) ;
454+
448455 extra. warnings . custom_warning (
449456 format ! (
450- "Failed to get discriminator value for tagged union serialization for {value } - defaulting to left to right union serialization."
457+ "Failed to get discriminator value for tagged union serialization {value_str } - defaulting to left to right union serialization."
451458 )
452459 ) ;
453460 }
You can’t perform that action at this time.
0 commit comments