Repository navigation
fix(api): don't split a character when capping git provider error detail - #854
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.
There was a problem hiding this comment.
Approach: sound — capping by runes is the minimal fix for the � in the error text, matches the existing gitsvc.ProviderMessage cap, and leaves ASCII output unchanged.
Reviewed changes — the full two-file diff at head 78e9d5d.
- Rune-safe cap in
providerDetail.services/api/internal/transport/http/handler/git_handler.gonow converts the redacted message to[]runeand slicesr[:300], so a multi-byte character straddling the cap is no longer cut in half; ASCII messages are byte-identical to before. - Table test for the cap.
TestProviderDetail_NeverCutsARuneInHalfcovers empty/whitespace, short, ASCII, accented, and emoji inputs. The focused tests pass locally (go test ./internal/transport/http/handler/ -run 'TestProviderDetail|TestGitHandler_ProviderMessage').
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
providerDetailin the git handler capped a provider's validation message withmsg[:300], so when byte 300 fell inside a multi-byte character the API error ended in half a rune and showed up as�. It now caps by runes, the same waygitsvc.ProviderMessagealready caps the settings-page message. ASCII messages are cut exactly as before.Added a small table test with accented text and emoji across the cap.
Fixes #853
Type of Change
Checklist