Repository navigation
fix(api): don't split a character when truncating git event text - #851
Conversation
Signed-off-by: dhananjay6561 <[email protected]>
Signed-off-by: dhananjay6561 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
@pikann small one: git event text cut at a byte limit could end in half a character, this keeps it on a whole rune. Happy to adjust if you'd prefer it elsewhere |
There was a problem hiding this comment.
ℹ️ No blocking issues — one non-blocking follow-up below.
Approach: sound — keep the existing byte caps and drop the partial rune after slicing, reusing the exact idiom already used in automation_consumer.go, so every automation payload site gets the fix without changing cap semantics.
Reviewed changes — reviewed both commits of the truncation fix, plus the call sites the helper feeds:
- Byte-safe truncation —
truncatenow pipes the capped prefix throughstrings.ToValidUTF8(..., ""), so the 500/2000/4000-byte automation caps and the 400-byte inbox reason end on a rune boundary. - Table test — covers the no-truncation path plus splits inside accented, CJK and emoji text;
go test ./internal/service/git/ -run TestTruncatepasses.
Non-blocking
buildPromptstill cuts the same event text mid-rune.prompt.go:157doestext[:maxEventText](6000 bytes) directly onev.Text, so the broken-character symptom this PR fixes for automation payloads can still appear in the agent prompt; swapping it for the now-safetruncate(text, maxEventText)would close it.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Summary
truncatein the git service cut by bytes, so a comment or review longer than its cap (500 / 2000 / 4000 bytes for automation payloads, 400 for the inbox reason) could end in half a multi-byte character, which shows up as a�in the automation event. It now drops the partial rune withstrings.ToValidUTF8, the same wayautomation_consumer.goalready caps event vars.Added a small table test with accented, CJK and emoji text.
Fixes #850
Type of Change
Checklist