You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: escape proto comments correctly in generated descriptions and schemas #100
Found while reviewing #99. Both bugs are in how proto comments become Go string literals and JSON Schema descriptions:
A backslash in an RPC or message comment breaks generation. For example, // matches \d+ produces Go that doesn't parse, because processCommentToString (cmd/protoc-gen-go-mcp/mcp.go) escapes only ". This already happens on main before the migration.
Fix: emit string literals with strconv.Quote (or %q) instead of hand-escaping.
Summary: processCommentToString no longer escapes "/\ itself (that was causing the double-escaping and the invalid-Go-literal bug); the tool Description field is now emitted with strconv.Quote, and the schema builder's raw comment text is escaped exactly once by encoding/json. Added ", \, a backtick and a newline to examples/protos/example.proto's SetVibeRequest.vibe field and the SetVibe RPC comment, regenerated the example and golden file, and added TestProcessCommentToString plus updated e2e assertions.
Checks: gofmt -l ., go vet ./..., go build ./..., go test ./..., and the golden-file test all pass — see the PR body for full output.
Activity
erikist commentedon Oct 8, 2026
🤖 Factory: picked up by dispatcher; working on branch factory/100-fix-escape-proto-comments-correctly-in.
docs: clarify processCommentToString's comment-stripping comment (#100)
erikist commentedon Oct 8, 2026
🤖 Factory: opened PR #101 to fix this: #101
Summary:
processCommentToStringno longer escapes"/\itself (that was causing the double-escaping and the invalid-Go-literal bug); the toolDescriptionfield is now emitted withstrconv.Quote, and the schema builder's raw comment text is escaped exactly once byencoding/json. Added",\, a backtick and a newline toexamples/protos/example.proto'sSetVibeRequest.vibefield and theSetVibeRPC comment, regenerated the example and golden file, and addedTestProcessCommentToStringplus updated e2e assertions.Checks:
gofmt -l .,go vet ./...,go build ./...,go test ./..., and the golden-file test all pass — see the PR body for full output.fix: escape proto comments correctly in generated descriptions and sc…