Skip to content

Fix phase-1/phase-2 validation gap in RESP decoder#4

Merged
jaredLunde merged 1 commit into
mainfrom
cursor/fix-validation-gap-26fe
Jul 5, 2026
Merged

Fix phase-1/phase-2 validation gap in RESP decoder#4
jaredLunde merged 1 commit into
mainfrom
cursor/fix-validation-gap-26fe

Conversation

@jaredLunde

Copy link
Copy Markdown
Contributor

Summary

The decoder used a two-phase design where frame_len validated structure and build_value performed semantic checks. When phase 2 failed, split_to had already removed bytes from the input buffer, causing silent data loss on malformed frames.

This moves semantic validation into phase 1 (count_value / frame_len) for:

  • Boolean (#t / #f)
  • Double (,)
  • Big number (()
  • Verbatim string (= colon separator and minimum length)

Decode errors on these types now return before any bytes are consumed.

Tests

  • Added boolean_invalid_byte unit test
  • Added semantic_error_leaves_buffer_unconsumed integration test covering double, big number, verbatim, and boolean semantic errors
Open in Web Open in Cursor 

Move semantic validation (boolean bytes, doubles, big numbers, verbatim
format) into frame_len/count_value so decode errors are returned before
split_to consumes input bytes.

Adds tests for invalid boolean wire form and buffer preservation on all
semantic error paths.

Co-authored-by: Jared Lunde <jared.lunde@gmail.com>
@jaredLunde jaredLunde marked this pull request as ready for review July 5, 2026 00:11
@cursor

cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@jaredLunde jaredLunde merged commit 257893e into main Jul 5, 2026
2 checks passed
@jaredLunde jaredLunde deleted the cursor/fix-validation-gap-26fe branch July 5, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants