Skip to content

fix(links): decode base64url dialog audio in the whisper links - #208

Merged
howethomas merged 3 commits into
mainfrom
thomashowe/con-1112-whisper-base64url
Sep 25, 2026
Merged

howethomas merged 3 commits into
mainfrom
thomashowe/con-1112-whisper-base64url

Conversation

@howethomas

Copy link
Copy Markdown
Contributor

The Groq and Hugging Face whisper links decoded inline dialog audio with plain base64.b64decode() whatever the dialog's encoding said. vCon core draft-04 allows only base64url, json or none for encoding, and producers are moving inline audio to unpadded base64url. On that input the old code either raised on the missing padding or, because b64decode does not validate by default, silently dropped - and _ and returned corrupted audio that was then transcribed.

Changes

  • common/lib/dialog_body.py: decode_inline_dialog_body(dialog) -> bytes decodes by encoding.
    • base64url: padding restored, then a validating decode. base64.urlsafe_b64decode is not used because it also skips validation.
    • base64, or no encoding (vCons stored before the field was required): validating standard decode.
    • Line breaks and other whitespace are stripped first, so MIME-style bodies wrapped at 76 columns still decode, as they did before.
    • none, any other value, or invalid characters: ValueError, never a guess.
  • Links: groq_whisper, hugging_face_whisper and wtf_transcribe use the helper. wtf_transcribe already branched on base64url but called urlsafe_b64decode without restoring padding, so it raised on unpadded bodies; fixed by the same change.
  • Other b64decode sites were checked and left alone: SCITT key material and signing keys are not dialog bodies. common/vcon.py's write-time base64url validation does not restore padding either; noted, out of scope here.

Tests

  • common/tests/lib/test_dialog_body.py: unpadded and padded base64url, legacy base64, missing encoding, bytes that encode to - and _ (asserting plain b64decode corrupts them and the helper does not), line-wrapped bodies, and every error path.
  • Per-link tests for Groq, Hugging Face (new file; the existing ones are commented out pending API keys) and wtf_transcribe, including unpadded base64url.
  • uv run pytest on the touched modules: 35 passed, 4 skipped (API-key and network gated), against 26 passed on main. The wider non-Docker suite: 684 passed, 20 skipped. The Redis-backed modules CI runs inside Docker were not run locally.

Refs CON-1112

🤖 Generated with Claude Code

howethomas and others added 3 commits September 25, 2026 17:55
draft-ietf-vcon-vcon-core-04 allows base64url, json or none as dialog
encoding, and telephony adapters are moving to unpadded base64url for
inline audio. Plain base64.b64decode either raises on the missing
padding or, in its default non-validating mode, silently drops "-"/"_"
and returns corrupted audio instead of raising.

decode_inline_dialog_body() dispatches on the dialog's own encoding:
base64url (with or without padding) via a validated decode, legacy
base64/missing encoding for vCons stored before encoding was mandatory,
and a clear ValueError for "none" or anything unrecognized rather than
guessing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
groq_whisper and hugging_face_whisper decoded inline dialog audio with
plain base64.b64decode(dialog["body"]) regardless of the dialog's
encoding field, which corrupts or rejects unpadded base64url bodies
from adapters moving to that encoding. wtf_transcribe already branched
on encoding == "base64url" but used a non-validating, unpadded
urlsafe_b64decode that has the same failure mode.

Switch all three to common/lib/dialog_body.decode_inline_dialog_body(),
which validates and pads as needed. URL-referenced (non-inline) dialogs
are unchanged in all three links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous non-validating decode skipped line breaks, so MIME-style
bodies wrapped at 76 columns decoded. Strip whitespace before the
validating decode so those keep working; other stray characters still fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@howethomas
howethomas merged commit ac37e41 into main Sep 25, 2026
1 check passed
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.

1 participant