Conversation
|
Good fix for the JSON escaping issue. A couple of observations:
The core approach (unmarshal JSON → walk + resolve templates → re-marshal) is correct and handles escaping properly. |
|
Review webhook.go:76: Condition checks w.Template != nil but immediately uses w.TemplateText. Since both are set together in NewWebhookDispatcher, the check works, but checking w.TemplateText != "" would be more semantically correct and eliminates the now-unused compiled template from the hot path. executeJSONTemplate: Re-parses JSON and recompiles templates on every call. The pre-compiled w.Template is now unused for JSON templates. Minor perf overhead but acceptable for a notification dispatcher. Non-JSON fallback still executes via raw text/template, meaning the original quote-escaping bug persists for non-JSON custom templates. Seems intentional but worth a comment clarifying this limitation. formatLogMessage in processing.go: Clean improvement over fmt.Sprintf("%v") for structured log entries. Test coverage is solid — quotes, newlines, backslashes, nested structures, and the non-JSON fallback path are all covered. One untested edge case: a JSON template where a placeholder renders a number (e.g., "count": "{{ .SomeInt }}"). The output stays a JSON string rather than a number. Unlikely to be a practical issue but worth awareness. |
ReviewThe approach is correct — parsing the template as JSON, resolving placeholders per-field, then re-marshaling is the right way to ensure proper escaping. Issues:
Good:
|
ReviewCore fix is correct — parsing template as JSON, resolving placeholders in string values, then re-marshaling is the right approach for proper escaping. Good test coverage. Issues:
|
|
Code review
|
|
Previous reviews covered the key points. Confirming the final state looks correct:
Remaining dead code: |
No description provided.