Skip to content

fix(api): don't split a character when capping git provider error detail - #854

Merged
pikann merged 2 commits into
Paca-AI:masterfrom
dhananjay6561:fix/provider-detail-rune-cap
Dec 3, 2026
Merged

pikann merged 2 commits into
Paca-AI:masterfrom
dhananjay6561:fix/provider-detail-rune-cap

Conversation

@dhananjay6561

Copy link
Copy Markdown
Contributor

Summary

providerDetail in the git handler capped a provider's validation message with msg[: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 way gitsvc.ProviderMessage already 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

  • Other (bug fix)

Checklist

  • The change is focused and scoped.
  • Related documentation is updated (no docs affected).
  • New structure or direction is explained clearly.
  • I avoided unnecessary detail or premature abstraction.

Copilot AI balanced review requested due to automatic review settings December 3, 2026 04:49
@dhananjay6561

Copy link
Copy Markdown
Contributor Author

@pikann small one in the same spirit as #851: the git provider error detail was cut at 300 bytes and could end in half a character, this caps it by runes like ProviderMessage does. Happy to adjust if you'd prefer it elsewhere

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.go now converts the redacted message to []rune and slices r[: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_NeverCutsARuneInHalf covers empty/whitespace, short, ASCII, accented, and emoji inputs. The focused tests pass locally (go test ./internal/transport/http/handler/ -run 'TestProviderDetail|TestGitHandler_ProviderMessage').

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit c95568d into Paca-AI:master Dec 3, 2026
6 checks 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.

[Bug] Capped Git provider error message can end in half a character

3 participants