Skip to content

Surface trailing bytes from parse_wal_message #79

Description

@LucaCappelletti94

LogicalReplicationParser::parse_wal_message(data: &[u8]) -> Result<StreamingReplicationMessage> and its sibling parse_wal_message_bytes(data: bytes::Bytes) both build a BufferReader internally and return only the parsed message. The reader knows how many bytes are still unread after a successful parse, but neither entry point exposes that count, so a caller that wants to reject a frame with trailing garbage (a valid Insert payload followed by [0xAA, 0xBB], for example) has no surface to do so.

A downstream pgoutput parser that previously errored on trailing bytes loses that check the moment it delegates to this API.

I intend therefore to add parse_wal_message_strict(&mut self, data: &[u8]) -> Result<StreamingReplicationMessage> that errors with a new ReplicationError::TrailingBytes { expected, actual } variant when BufferReader::remaining() is non-zero after parsing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions