File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
packages/libs/restate-sdk-core/src Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -112,23 +112,41 @@ class StandardSchemaSerde<
112112 // Standard Schema validate can return a Promise, but Serde must be synchronous
113113 if ( result && typeof result === "object" && "then" in result ) {
114114 throw new TypeError (
115- "Async validation is not supported in Serde. The schema must support synchronous validation."
115+ "Async validation is not supported in Serde. Restate SDK supports only synchronous validation."
116116 ) ;
117117 }
118118
119119 if ( result . issues ) {
120120 const errorMessages = result . issues
121- . map ( ( issue : StandardSchemaV1 . Issue ) => issue . message )
122- . join ( ", " ) ;
121+ . map ( formatStandardSchemaIssue )
122+ . join ( "\n " ) ;
123123 throw new TypeError (
124- `Standard schema validation failed: [ ${ errorMessages } ] `
124+ `Standard schema validation failed:\n ${ errorMessages } `
125125 ) ;
126126 }
127127
128128 return result . value as StandardSchemaV1 . InferOutput < T > ;
129129 }
130130}
131131
132+ function formatStandardSchemaIssue ( issue : StandardSchemaV1 . Issue ) : string {
133+ if ( issue . path && issue . path . length > 0 ) {
134+ const jsonPointer =
135+ "/" +
136+ issue . path
137+ . map ( ( p ) => {
138+ // Handle both PathSegment objects and primitive PropertyKey values
139+ if ( typeof p === "object" && p !== null && "key" in p ) {
140+ return String ( p . key ) ;
141+ }
142+ return String ( p ) ;
143+ } )
144+ . join ( "/" ) ;
145+ return `* (at ${ jsonPointer } ) ${ issue . message } ` ;
146+ }
147+ return `* ${ issue . message } ` ;
148+ }
149+
132150function isStandardJSONSchemaV1 ( standard : StandardSchemaV1 . Props ) : boolean {
133151 return (
134152 standard != undefined &&
You can’t perform that action at this time.
0 commit comments