fix(reporter): handle binary metadata in v4 message logs#15779
fix(reporter): handle binary metadata in v4 message logs#15779
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> chore: make sed commands portable across macOS and Linux [skip ci] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> chore: improve auth comments to explain why, not what [skip ci] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> chore: use ALPHA_VERSION variable in helm push command [skip ci] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> chore: use ALPHA_VERSION variable in cloud-apim Chart.yaml [skip ci] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> chore: use awk to safely clear artifacthub changes block [skip ci] Replace sed commands that could corrupt Chart.yaml if artifacthub.io/changes is not the last section in the file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> chore: split sed and rm cleanup onto separate lines [skip ci] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the external CDN script for Redoc with a locally bundled copy served from assets. This is more secure, works in closed-circuit environments, and does not require nginx CSP changes. Made-with: Cursor
connectionhandleradapter
…-alpha.6 Ref: APIM-13126
(cherry picked from commit c58ac73)
handle migration of tags, replacing the use of `id` with the `key` field and generating new UUIDs for tag IDs.
(cherry picked from commit 2f5b4b1)
Change the `v` column type from nvarchar(1000) to nclob to support larger property values. nclob is suitable here since dictionary property values are not indexed. https://gravitee.atlassian.net/browse/APIM-12355 (cherry picked from commit 7220404) # Conflicts: # gravitee-apim-repository/gravitee-apim-repository-jdbc/src/main/resources/liquibase/master.yml
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical FreeMarker template error that previously caused Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a FreeMarker template error that occurs when processing binary metadata by adding logic to skip sequence types like byte[]. The fix is applied consistently across all relevant Elasticsearch reporter configurations. I've added one suggestion to refactor the template logic for improved readability and maintainability, which applies to all three modified files.
| <#assign first = true> | ||
| <#list log.getMessage().getMetadata() as metadataKey, metadataValue> | ||
| "${metadataKey}": "${metadataValue?j_string}" | ||
| <#sep>,</#sep> | ||
| <#if metadataValue?? && !metadataValue?is_sequence> | ||
| <#if !first>,</#if>"${metadataKey}": "${metadataValue?string?j_string}"<#assign first = false> | ||
| </#if> | ||
| </#list> |
There was a problem hiding this comment.
While the current implementation with manual comma handling is correct, it can be simplified and made more readable by separating the filtering of metadata from the rendering. You could first build a new map containing only the printable metadata, and then iterate over that new map using <#sep> for cleaner comma separation. This approach is generally less error-prone and easier to maintain.
This comment also applies to the identical changes in es8x/index/v4-message-log.ftl and es9x/index/v4-message-log.ftl.
<#assign printable_metadata = {}>
<#list log.getMessage().getMetadata() as metadataKey, metadataValue>
<#if metadataValue?? && !metadataValue?is_sequence>
<#assign printable_metadata = printable_metadata + {metadataKey: metadataValue}>
</#if>
</#list>
<#list printable_metadata as metadataKey, metadataValue>
"${metadataKey}": "${metadataValue?string?j_string}"<#sep>,</#sep>
</#list>
|



Issue
gravitee-io/issues#11220
Description
This PR fixes a FreeMarker template error in
v4-message-log.ftlthat occurred when processing binary metadata (e.g., from Kafka).The issue was that
byte[]metadata values were being treated as sequences by FreeMarker, causing the?j_stringand?stringbuilt-ins to fail withUnexpectedTypeException.Changes:
v4-message-log.ftlines7x,es8x, andes9xreporter configurations.<#sep>. This approach is cleaner and more maintainable than manual comma handling.Additional context
Refined Implementation
All 99 tests in
gravitee-apim-reporter-commonpassed.