Repository navigation
Chore/greptile json codec rule - #2667
Merged
mromaszewicz merged 2 commits intoNov 11, 2026
Merged
Conversation
.greptile/config.json began with two opening braces, so it has not been valid JSON since it was last edited, and the strictness and *.gen.go settings in it could not be parsed. Remove the extra brace. .greptile/rules.md had two sections numbered 5. The schema-merging rule, which comes last, becomes section 8. Co-Authored-By: Claude <noreply@anthropic.com>
Generated code is moving to the process-wide JSON codec in runtime v1.9.0 (oapi-codegen#2665), so that runtime.SetJSONCodec applies to all of it. A template that calls encoding/json directly escapes the codec without any test noticing, because the default codec is encoding/json. Add a review rule that flags direct json.Marshal, json.Unmarshal, json.NewEncoder and json.NewDecoder calls in templates and in code that emits generated source, names the runtime function to use for each, and protects the buffer-before-WriteHeader ordering of the strict response. It lists what is exempt: json.RawMessage, json.Number, json.Valid, the UseNumber probe in the union template, JSON a web framework handles, and the generator's own use of encoding/json. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
[Low impact] The PR appears safe to merge, with the existing non-blocking wording concern still open. Findings
Fix with agent prompt### Issue 1
.greptile/rules.md:undefined-119
The new rule describes a migration that the current templates have not made. `client.tmpl:119` still emits `json.Marshal(body)`, and `strict/strict-interface.tmpl:92` still emits `json.NewEncoder(&buf).Encode(...)`, not `runtime.JSONMarshalWrite`. This could lead maintainers to believe one `runtime.SetJSONCodec` call already covers all generated JSON.
Describe codec use as a requirement for future changes instead. Keep the buffering requirement, which matches the current strict response template.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds review guidance for generated JSON to use the runtime codec.
Reviews (2) · Last reviewed commit: "chore: add a Greptile rule that generate..." · Reviewed by Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated code is moving to the process-wide JSON codec in runtime
v1.9.0 (#2665), so that runtime.SetJSONCodec applies to all of it. A
template that calls encoding/json directly escapes the codec without any
test noticing, because the default codec is encoding/json.
Add a review rule that flags direct json.Marshal, json.Unmarshal,
json.NewEncoder and json.NewDecoder calls in templates and in code that
emits generated source, names the runtime function to use for each, and
protects the buffer-before-WriteHeader ordering of the strict response.
It lists what is exempt: json.RawMessage, json.Number, json.Valid, the
UseNumber probe in the union template, JSON a web framework handles, and
the generator's own use of encoding/json.
Co-Authored-By: Claude noreply@anthropic.com