fix(metadata): accept raw-DEFLATE appData and surface decode causes#91
Open
insipx wants to merge 1 commit into
Open
fix(metadata): accept raw-DEFLATE appData and surface decode causes#91insipx wants to merge 1 commit into
insipx wants to merge 1 commit into
Conversation
ApprovabilityVerdict: Needs human review This PR adds a new decompression fallback path (raw DEFLATE for iOS compatibility) and new input validation to the appData parsing logic. While well-tested and maintaining backward compatibility on the lenient path, these changes alter runtime data processing behavior and warrant human review. You can customize Macroscope's approvability policy. Learn more. |
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
convos-cli cannot read appData written by convos-ios: iOS compresses with Apple's
COMPRESSION_ZLIB, which emits raw DEFLATE (no zlib header), whiledecompressIfNeededuses NodeinflateSync(zlib-wrapped only). Any >100-byte iOS-written appData hitsZ_DATA_ERROR, which the lenient parser swallows into empty metadata — the root cause of herald'sGET /metadata502s (CON-627) and a contributor to iOS-side profile loss ("Somebody" names, since the reverse direction is equally broken).decompressIfNeeded: tryinflateSync, fall back toinflateRawSync— both formats decode; when both fail the zlib error (our canonical format) is surfaced. Size guard unchanged.decodeAppData) soparseAppDataForWriteattaches the ORIGINAL decode error ascauseon its guard throw (undecodable case), while a decoded-but-tagless blob throws without cause — the two are now distinguishable in telemetry. Throw message text unchanged.Buffer.from(str, "base64url")silently drops invalid chars, so garbage previously masqueraded as decoded-but-empty metadata; it now fails the decode with a real error. LenientparseAppDatabehavior is unchanged (still returns empty on any failure).Verification
990db8c5…): previously parsed as empty → now decodes to its actual contents (tag, 32-byte imageEncryptionKey, 4 profiles) andparseAppDataForWritesucceeds.pnpm typecheckhas one pre-existing error on main (send-remote-attachment.ts:97, unrelated file).Follow-ups (not this PR)
deflateRawSyncafter fleet-wide reader deployment.commands/conversation/lock.ts,invite.ts,agent/serve.tslenient-parse beforeserializeAppData— same clobber class the strict guard protects against; flagged during adversarial review.🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Fix
parseAppDataandparseAppDataForWriteto accept raw-DEFLATE compressed appDatadecompressIfNeededin metadata.ts to first attempt zlib-wrapped inflate, then fall back to raw DEFLATE (inflateRawSync) to support iOS-produced compressed payloads.decodeAppDatainternal function that centralizes strict decoding with explicit base64url validation, replacing silent acceptance of invalid inputs that previously decoded to empty bytes.parseAppDataForWriteto use strict decoding and attach the underlying decode error ascausewhen it throws, improving debuggability.parseAppDataForWrite(withcause), whileparseAppDatacontinues to return empty metadata leniently.Macroscope summarized 1e07c13.