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;
8
8
use crate :: build_tools:: py_schema_err;
9
9
use crate :: common:: union:: { Discriminator , SMALL_UNION_THRESHOLD } ;
10
10
use crate :: definitions:: DefinitionsBuilder ;
11
+ use crate :: errors:: write_truncated_to_50_bytes;
11
12
use crate :: lookup_key:: LookupKey ;
12
13
use crate :: serializers:: type_serializers:: py_err_se_err;
13
- use crate :: tools:: SchemaDict ;
14
+ use crate :: tools:: { safe_repr , SchemaDict } ;
14
15
use crate :: PydanticSerializationUnexpectedValue ;
15
16
16
17
use super :: {
@@ -445,9 +446,15 @@ impl TaggedUnionSerializer {
445
446
Discriminator :: Function ( func) => func. call1 ( py, ( value, ) ) . ok ( ) ,
446
447
} ;
447
448
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
+
448
455
extra. warnings . custom_warning (
449
456
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."
451
458
)
452
459
) ;
453
460
}
You can’t perform that action at this time.
0 commit comments