Repository navigation
refactor(mcp): replace embedded template in FormatAppliedFilter with pure Go - #1204
Merged
Merged
Conversation
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
October 30, 2026 08:45
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the markdown template rendering for applied filters by replacing the Go template engine with direct Go string manipulation. The FormatAppliedFilter function has been moved to a new file, applied_filter.go, and the corresponding .tmpl file has been removed. The test suite has also been updated to handle dynamic markdown code block fences. The review feedback suggests a minor optimization to replace strings.Builder with simple string concatenation for the final markdown output to improve readability.
Merged
via the queue into
GoogleCloudPlatform:main
with commit Oct 30, 2026
c362c1f
17 checks passed
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.
Summary
All other Markdown helpers in
pkg/server/mcp/mdtemplateare implemented as pure Go functions, whereasFormatAppliedFilterrelied on an embeddedtext/templatefile (templates/applied_filter.md.tmpl) andpanic(err)to render a fixed six-field YAML block with a hardcoded triple-backtick code fence. When a CEL filter expression contained triple backticks, the hardcoded fence prematurely closed the Markdown code block.This change replaces the embedded template with a pure Go implementation in
applied_filter.gothat constructs the YAML block directly and wraps it usingmd.Fence("yaml", ...), automatically expanding the outer code fence whenever a query contains triple backticks while keepingtemplate.gofocused on generic template infrastructure.