@mastra/observability 1.17.2-alpha.0 → 1.17.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mastra/observability
2
2
 
3
+ ## 1.17.2-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix PostgreSQL observability writes failing on NUL characters and unpaired Unicode surrogates ([#21728](https://github.com/mastra-ai/mastra/pull/21728))
8
+
9
+ Span serialization truncated strings by UTF-16 code unit, so a cut inside an emoji left a lone surrogate that PostgreSQL rejected on the jsonb cast (`22P02`). NUL characters were rejected as well (`22P05`). Because observability events are inserted as a single multi-row statement, one malformed field discarded the entire batch.
10
+
11
+ Truncation now preserves complete surrogate pairs, and the v-next PostgreSQL observability encoder sanitizes NUL and unpaired surrogates before the jsonb cast, using the same sanitizer that workflow snapshots already rely on. Valid Unicode, including complete emoji, is preserved.
12
+
13
+ - Updated dependencies [[`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781)]:
14
+ - @mastra/core@1.62.0-alpha.3
15
+
3
16
  ## 1.17.2-alpha.0
4
17
 
5
18
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -246,10 +246,18 @@ function mergeSerializationOptions(userOptions) {
246
246
  }
247
247
  /**
248
248
  * Hard-cap any string to prevent unbounded growth.
249
+ *
250
+ * The cut never splits a UTF-16 surrogate pair: if it would land immediately
251
+ * after a lone high surrogate (U+D800..U+DBFF), it backs off one code unit so
252
+ * the pair is dropped as a whole. `JSON.stringify` emits a lone `\ud83d` for a
253
+ * split pair, which PostgreSQL rejects on a jsonb cast with 22P02
254
+ * ("Unicode low surrogate must follow a high surrogate").
249
255
  */
250
256
  function truncateString(s, maxChars) {
251
257
  if (s.length <= maxChars) return s;
252
- return s.slice(0, maxChars) + "…[truncated]";
258
+ const code = s.charCodeAt(maxChars - 1);
259
+ const safeEnd = code >= 55296 && code <= 56319 ? maxChars - 1 : maxChars;
260
+ return s.slice(0, safeEnd) + "…[truncated]";
253
261
  }
254
262
  function formatSerializationError(error) {
255
263
  return `[${error instanceof Error ? truncateString(error.message, 256) : "unknown error"}]`;