fix(graph): rune-based truncation in dotEscape prevents invalid UTF-8 in DOT output#105
Conversation
writeGraphData computed lineCount only when startLine > 0 && endLine > 0. For nodes without a startLine (API returns 0), the condition was false and lineCount remained 0, so the graph visualisation data showed lc=0 even though the same node's frontmatter correctly computed line_count=endLine (using effectiveStart=1). Fix: mirror the effectiveStart=1 defaulting used by all frontmatter writers — if endLine > 0 but startLine <= 0, treat startLine as 1. Adds TestGraphDataLineCountMissingStartLine to catch the regression. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
goimports rejects manually aligned spaces; use single space. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dotEscape used byte indexing (s[len(s)-39:]) to take the last 39 characters of a node name. For names with multi-byte UTF-8 characters (e.g. accented letters, CJK paths), the byte offset could land in the middle of a multi-byte sequence, producing invalid UTF-8 in the DOT output and breaking downstream Graphviz tools. Fix: convert to []rune and slice by rune index. Adds TestWriteDOT_LongNameTruncated_MultiByteUTF8 as a regression test (41 × "é" → the old byte slice cut byte 43, which is the second byte of U+00E9, producing invalid UTF-8). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 12 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
dotEscapeininternal/graph/handler.goused byte-based indexing (s[len(s)-39:]) to trim long node names in DOT graph output.dotfile causes Graphviz and other DOT consumers to fail or emit garbage[]rune, compare and slice by rune indexRegression test
TestWriteDOT_LongNameTruncated_MultiByteUTF8: 41 ×"é"(2 bytes each = 82 bytes, 41 runes). The olds[82-39:]=s[43:]starts at the second byte ofU+00E9(encoded0xC3 0xA9), producing invalid UTF-8. The fix slices by rune index and produces valid UTF-8 with the correct 39-rune tail.Test plan
go test ./internal/graph/— all tests pass including new regression testgo build ./...— clean🤖 Generated with Claude Code