fix(CON-352): correct body serialization/deserialization for analysis and attachments#39
Merged
pavanputhra merged 1 commit intomainfrom Mar 23, 2026
Conversation
… and attachments Bodies stored in the TEXT column with encoding='none' were returned as JSON strings instead of their original object/array form. The fix uses the encoding field to drive both directions: stringify on write when encoding is 'none' or unset and body is not already a string; parse on read under the same condition. - Add src/utils/body-serialization.ts with serializeBody and deserializeBody helpers - Apply serialization in queries.ts addAnalysis and addAttachment - Apply deserialization in queries.ts getVCon for analysis and attachment rows - Use deserializeBody in resources/index.ts and encoding-aware logic in tenant-config.ts - Update Analysis and Attachment types: body typed as unknown to allow objects and arrays Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
analysisandattachmentswithencoding='none'were returned as JSON strings instead of their original object/array form after a save/retrieve round-tripencodingfield now drives both directions: serialize on write, parse on readsrc/utils/body-serialization.tswith sharedserializeBodyanddeserializeBodyhelpers used across the codebaseChanges
src/utils/body-serialization.ts— new shared helpers for body encode/decodesrc/db/queries.ts— apply serialize/deserialize inaddAnalysis,addAttachment, andgetVConsrc/resources/index.ts— usedeserializeBodyinstead of ad-hoc type checksrc/config/tenant-config.ts— use encoding field to decide how to interpret bodysrc/utils/validation.ts— handle body already being a parsed objectsrc/types/vcon.ts— typebodyasunknownto allow objects, arrays, and stringsTest plan
analysis[].bodyas a JSON object andencoding: "none"— GET should return the body as an object, not a stringattachments[].bodyencoding: "json"should remain as strings on retrievalencoding: "base64url"should remain as strings on retrievalFixes CON-352
🤖 Generated with Claude Code