Skip to content

Fix number format in Rule Builder #25218

Open
patrickmann wants to merge 2 commits intomasterfrom
fix/issue-23541
Open

Fix number format in Rule Builder #25218
patrickmann wants to merge 2 commits intomasterfrom
fix/issue-23541

Conversation

@patrickmann
Copy link
Contributor

@patrickmann patrickmann commented Mar 4, 2026

Resolves #23541

Description

  • Fix pipeline rule builder "mismatched input" parse error when numeric condition values exceed 999
  • Root cause: Freemarker's default locale-aware number formatting inserts thousand separators (e.g., 1,000) into generated rule source code, which the ANTLR parser rejects
  • Set numberFormat("computer") on the rule builder's Freemarker configurations to produce separator-free numbers
  • Also fixes the cosmetic display of numbers in condition titles

Details

The SecureFreemarkerConfigProvider is a Guice Provider that acts as a factory — each call to get() returns a new Configuration instance. This is a deliberate design choice: different consumers (rule builder, email templates, etc.) can customize their instance without affecting others. That's why the fix is safe — setting numberFormat("computer") on the rule builder's instance doesn't change how email templates format numbers.

The two separate Configurations matter: RuleBuilderRegistry owns the config for generating rule source code (fragment templates like to_long($message.${field}) <= ${fieldValue}). RuleBuilderService owns a separate config for generating display titles (like Field 'bytes' greater than or equal '10000'). Both needed the fix independently because they create their own Configuration instances from SecureFreemarkerConfigProvider.get().

Test

  • Added ParserUtilTest verifying fragment generation with numbers > 999 produces no thousand separators
  • Added RuleBuilderServiceTest verifying title generation with numbers > 999 produces no thousand separators
  • All existing tests pass

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Pipeline Rule Builder failures when numeric condition values exceed 999 by preventing Freemarker locale-specific thousand separators from being inserted into generated rule source and condition/action titles.

Changes:

  • Configure Rule Builder Freemarker Configuration instances to use numberFormat("computer") (no thousand separators).
  • Add regression tests ensuring generated fragments and titles for values > 999 contain no separators.
  • Add an unreleased changelog entry for the fix.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/rulebuilder/parser/RuleBuilderService.java Sets Freemarker number format to computer for title template rendering.
graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/rulebuilder/RuleBuilderRegistry.java Sets Freemarker number format to computer for fragment template rendering used in rule source generation.
graylog2-server/src/test/java/org/graylog/plugins/pipelineprocessor/rulebuilder/parser/ParserUtilTest.java Adds config + test asserting fragment rendering doesn’t introduce thousand separators for large numbers.
graylog2-server/src/test/java/org/graylog/plugins/pipelineprocessor/rulebuilder/parser/RuleBuilderServiceTest.java Adds test asserting title rendering doesn’t introduce thousand separators for large numbers.
changelog/unreleased/issue-23541.toml Adds release note entry for issue #23541.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@patrickmann patrickmann marked this pull request as ready for review March 4, 2026 14:45
@patrickmann patrickmann requested a review from a team March 4, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipeline Rule builder errors on numeric values in WHEN clause

2 participants