Skip to content

fix(P2): chat server silently degrades to byte-level decode on tokenizer error #337

@noahgift

Description

@noahgift

Bug

serve/chat.rs:306 and serve/simple.rs:85 use .unwrap_or_else(|_| simple_decode(...)) on tokenizer decode. When BPE decode fails, the server silently falls back to byte-level decoding, sending garbage to API consumers.

Impact

API consumers get garbled output with no indication of tokenizer failure.

Files

  • crates/apr-cli/src/commands/serve/chat.rs:306
  • crates/apr-cli/src/commands/serve/simple.rs:85

Fix

Log warning on decode fallback, include X-Decode-Fallback: true header or note in response metadata.

Found by: batuta bug-hunter analyze (SilentDegradation category)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions