Repository navigation
fix(civitai): snippet cuts a server body on a rune boundary, not a byte index - #972
Conversation
Committed before the fix so CI shows it red. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…te index The 500-byte bound now backs up to utf8.RuneStart, so the SDK's error text is always valid UTF-8 and keeps 497-500 bytes. The short-body invariant guard moves to exactly 500 bytes (round-0 audit D1). Fixes #627 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Audit round 0 (requirements & deletion) at D1 applied in the fix commit (the guard now sits exactly on the 500-byte boundary). D2 kept: |
Round-1 audit of #972: a body of bare continuation bytes (invalid UTF-8, passed through by saferune.Strip) backed the cut to nothing. The loop now stops within utf8.UTFMax of the budget, and the comment scopes the 497-500 claim to valid UTF-8. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Audit round 1 (nine axes) at |
Fixes #627
What
pkg/civitai'ssnippetbounded a server body at 500 bytes withs[:max]. A body whose 500th byte fell inside a multi-byte rune came back as invalid UTF-8 inside the SDK's error string. The cut now backs up to the nearest rune start (utf8.RuneStart), so it keeps at most 500 bytes and at least 497.Tests
pkg/civitai/snippet_rune_boundary_test.go, committed first on its own so CI shows it red:TestSnippetCutsOnARuneBoundary: the issue's CJK fixture at four alignments, plus 4-byte emoji (regression). Thev2alignment happens to land on a boundary and is valid before the fix too.TestSnippetLeavesABodyAtTheBudgetAlone: invariant guard (exactly 500 bytes; renamed after round-0 D1)TestSnippetBoundsTheBackUpOnInvalidBytes: added after round 1🤖 Generated with Claude Code