allthingssecurity commented on PR #31015: URL: https://github.com/apache/camel/pull/31015#issuecomment-7222930556
Thanks, good catch on the NUL. I went with failing rather than dropping it. The transformer now throws an IllegalArgumentException that names the key and says whether its name or its value has the NUL, for example "The value of the metadata key 'author' has a NUL character (U+0000), which PostgreSQL jsonb cannot store". Dropping it would store a value that differs from what the route sent with nothing to show for it, and failing keeps the error at the write, where it was before this change when PostgreSQL refused the raw NUL in the TEXT column, only with a clearer message. It fits the transformer too, which already throws an IllegalArgumentException when the embedding header is missing. The check is a small rejectNul() in front of escapeJson(), so the escaper itself is unchanged and other metadata is written byte for byte as before. PgVectorEmbeddingsMetadataJsonTest has two new tests, one with a NUL in a value and one with a NUL in a key, and both check the exact message. Without the change they fail because nothing is thrown. On NaN and Infinity: you are right, a Float or Double NaN or Infinity is written bare, which is not valid JSON either. I would rather keep that out of this PR and do it as a follow-up (writing them as null, or failing the same way as for the NUL, whichever you prefer). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
