Skip to content

refactor(mcp): replace embedded template in FormatAppliedFilter with pure Go - #1204

Merged
kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-pknpnkzkwqpy
Oct 30, 2026
Merged

kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-pknpnkzkwqpy

Conversation

@kyasbal

@kyasbal kyasbal commented Oct 30, 2026

Copy link
Copy Markdown
Member

Summary

All other Markdown helpers in pkg/server/mcp/mdtemplate are implemented as pure Go functions, whereas FormatAppliedFilter relied on an embedded text/template file (templates/applied_filter.md.tmpl) and panic(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.go that constructs the YAML block directly and wraps it using md.Fence("yaml", ...), automatically expanding the outer code fence whenever a query contains triple backticks while keeping template.go focused on generic template infrastructure.

@kyasbal kyasbal added area:backend-core Core backend frameworks, DAG task runner, and server API type:refactor Code refactoring without behavioral change labels Oct 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kyasbal
kyasbal added this pull request to the merge queue Oct 30, 2026
Merged via the queue into GoogleCloudPlatform:main with commit c362c1f Oct 30, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-pknpnkzkwqpy branch October 30, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API type:refactor Code refactoring without behavioral change

1 participant