-
Notifications
You must be signed in to change notification settings - Fork 142
Fix commas in JSONSchema descriptions and add linter #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hmm the branch name is wrong (I started on another issue and got distracted) but I don't think that's a biggie. |
0933a84
to
c90f0b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, the only thing was i couldn't spot how this is integrated in CI?
and is integrated in CI so we should catch this in future.
Shouldn't we have a make lint
or something in the CI? I also don't see this in the Github actions output either: https://github.com/grafana/mcp-grafana/actions/runs/14501420096/job/40681760901?pr=98
Oh yeah good call! We use the golangci-lint action in CI rather than make lint, we should fix that, I'll do it tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, though I think the linter could fail in at least one case. Not sure how perfect we need to be...
// It captures: | ||
// 1. The jsonschema tag | ||
// 2. Parts of the description containing unescaped commas | ||
var tagPattern = regexp.MustCompile(`jsonschema:"([^"]*)description=([^"]*[^\\],[^"]*)"`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fail if we use escaped quotes then have a comma inside of a jsonschema tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did not! I pushed a second commit which fixes & adds a test case for that.
Commas in jsonschema `description` fields inside struct field tags need to be escaped; otherwise, they're treated as another field and the description is silently truncated. This commit fixes all instances of that, and adds a linter which checks for the presence of any unescaped commas in the `jsonschema` descriptions. The linter also includes a `--fix` mode to automatically fix any issues, and is integrated in CI so we should catch this in future. (Thanks Claude & Zed!)
c90f0b9
to
ad2cb95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small comment, but 👍
* Fix commas in JSONSchema descriptions and add linter Commas in jsonschema `description` fields inside struct field tags need to be escaped; otherwise, they're treated as another field and the description is silently truncated. This commit fixes all instances of that, and adds a linter which checks for the presence of any unescaped commas in the `jsonschema` descriptions. The linter also includes a `--fix` mode to automatically fix any issues, and is integrated in CI so we should catch this in future. (Thanks Claude & Zed!) * Handle escaped quotes then commas in linter * Run custom linter in CI * Just use make lint in CI
Commas in jsonschema
description
fields inside struct field tags needto be escaped; otherwise, they're treated as another field and the
description is silently truncated. This commit fixes all instances of
that, and adds a linter which checks for the presence of any unescaped
commas in the
jsonschema
descriptions. The linter also includes a--fix
mode to automatically fix any issues, and is integrated in CI sowe should catch this in future. (Thanks Claude & Zed!)