Skip to content

fix(syslog): quote payloadKey path to prevent VRL evaluation as expression#3327

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
vparfonov:log9562
Jul 7, 2026
Merged

fix(syslog): quote payloadKey path to prevent VRL evaluation as expression#3327
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
vparfonov:log9562

Conversation

@vparfonov

@vparfonov vparfonov commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

Root Cause:

The payloadKey path (e.g., .message) was injected unquoted into the VRL template:
payload_key = .message # evaluates as VRL expression, reads the VALUE of .message

This resolved .message to its runtime value (e.g., "Hello World"), which was then treated as a field path looking for a field literally named "Hello World", which doesn't exist.

For payloadKey: "{.message}" this only produced noisy warnings (since .message was left unchanged). For any other field (e.g., {.kubernetes.namespace_name}), it silently failed to set .message to the intended value.

Fix:

Quote the path as a string literal and strip the leading dot before splitting:

payload_key = ".message"   # string literal, stays as a path
  if starts_with(payload_key, ".") {
    payload_key = slice!(payload_key, 1)
  }
  path = split!(payload_key, ".")
  value, err = get(., path)

/cc @Clee2691
/assign @jcantrill

Links

Summary by CodeRabbit

  • New Features
    • Improved syslog message extraction when using a configured payload key.
    • Enhanced handling for payload keys coming from structured JSON content (RFC5424).
  • Bug Fixes
    • Removed inconsistent skip-and-warning behavior when the configured payload field is missing or empty.
    • When lookup fails, syslog now reliably falls back to a cleaned-up message derived from the event.
  • Tests
    • Added functional coverage for RFC5424 payload key behavior with structured input.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 2, 2026
@openshift-ci

openshift-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3e8b3f89-2f1f-4c35-a236-49e701dfe02d

📥 Commits

Reviewing files that changed from the base of the PR and between 13d2170 and 355dd57.

📒 Files selected for processing (4)
  • internal/generator/vector/output/syslog/syslog.go
  • internal/generator/vector/output/syslog/tls_with_field_references.toml
  • internal/generator/vector/output/syslog/udp_with_every_setting.toml
  • test/functional/outputs/syslog/rfc5424_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • internal/generator/vector/output/syslog/udp_with_every_setting.toml
  • test/functional/outputs/syslog/rfc5424_test.go
  • internal/generator/vector/output/syslog/syslog.go
  • internal/generator/vector/output/syslog/tls_with_field_references.toml

📝 Walkthrough

Walkthrough

Syslog payload_key handling now normalizes configured paths, performs deterministic lookups, and falls back to building .message when the lookup does not resolve. The generated TOML fixtures and an RFC5424 functional test were updated to match.

Changes

Syslog payload_key handling

Layer / File(s) Summary
VRL lookup and fallback
internal/generator/vector/output/syslog/syslog.go
payloadKeyConfiguredVRL now quotes the configured key, strips a leading dot, always runs get(., path), and falls back to message construction when the lookup does not return a non-null value.
Golden remap fixtures
internal/generator/vector/output/syslog/tls_with_field_references.toml, internal/generator/vector/output/syslog/udp_with_every_setting.toml
The syslog remap fixtures now use fixed payload key literals, path splitting, and lookup-based assignment without the previous warn-and-skip branch.
RFC5424 functional coverage
test/functional/outputs/syslog/rfc5424_test.go
A new functional test verifies structured field extraction into syslog payload output and confirms the missing-key warning is not emitted.

Estimated code review effort: 2 (Simple) | ~12 minutes

Suggested labels: lgtm

Suggested reviewers: alanconway, cahartma, jcantrill

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main fix: quoting the syslog payloadKey path to avoid VRL expression evaluation.
Description check ✅ Passed The description covers the root cause, fix, /cc, /assign, and a related JIRA link, so it matches the template well.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@vparfonov

Copy link
Copy Markdown
Contributor Author

/test functional-target

2 similar comments
@vparfonov

Copy link
Copy Markdown
Contributor Author

/test functional-target

@vparfonov

Copy link
Copy Markdown
Contributor Author

/test functional-target

@vparfonov vparfonov marked this pull request as ready for review July 2, 2026 19:28
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 2, 2026
@openshift-ci openshift-ci Bot requested review from Clee2691 and cahartma July 2, 2026 19:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/generator/vector/output/syslog/syslog.go (1)

126-143: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Escape payloadKey before embedding it in VRL
payloadKey allows quoted field-path segments (for example {."foo.bar"}), but fmt.Sprintf(payloadKeyConfiguredVRL, key) inserts the raw path into payload_key = "%s". Any embedded " or \ will produce invalid VRL and prevent the syslog transform from compiling. Escape the value here, or reject quoted segments.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/generator/vector/output/syslog/syslog.go` around lines 126 - 143,
The payloadKeyConfiguredVRL template in syslog.go is embedding the raw
payloadKey into a quoted VRL string, which can break compilation when the key
contains quoted path segments or escape characters. Update the syslog VRL
generation path that formats payloadKeyConfiguredVRL so the key is safely
escaped before being passed to fmt.Sprintf, or validate/reject unsupported
quoted segments in the payload key handling logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/generator/vector/output/syslog/syslog.go`:
- Around line 126-143: The payloadKeyConfiguredVRL template in syslog.go is
embedding the raw payloadKey into a quoted VRL string, which can break
compilation when the key contains quoted path segments or escape characters.
Update the syslog VRL generation path that formats payloadKeyConfiguredVRL so
the key is safely escaped before being passed to fmt.Sprintf, or validate/reject
unsupported quoted segments in the payload key handling logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4aeb287b-52d2-4e20-88c8-afd51d67a6b4

📥 Commits

Reviewing files that changed from the base of the PR and between c02ef14 and cb9fcb7.

📒 Files selected for processing (5)
  • Makefile
  • internal/generator/vector/output/syslog/syslog.go
  • internal/generator/vector/output/syslog/tls_with_field_references.toml
  • internal/generator/vector/output/syslog/udp_with_every_setting.toml
  • test/functional/outputs/syslog/rfc5424_test.go

@jcantrill

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 2, 2026
@vparfonov

Copy link
Copy Markdown
Contributor Author

/retest-required

2 similar comments
@vparfonov

Copy link
Copy Markdown
Contributor Author

/retest-required

@vparfonov

Copy link
Copy Markdown
Contributor Author

/retest-required

@jcantrill jcantrill 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.

/hold

Comment thread Makefile
Comment thread Makefile Outdated
@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 6, 2026
@jcantrill

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci

openshift-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jcantrill, vparfonov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@openshift-ci

openshift-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jcantrill, vparfonov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vparfonov

Copy link
Copy Markdown
Contributor Author

/retest-required

…ssion

The payloadKey was injected unquoted into VRL, causing it to be evaluated
as a field access expression rather than kept as a path string. This meant
the resolved value was then re-interpreted as a path via split+get, which
always failed, producing repeated "payload_key not found" warnings.

Fixes: LOG-9562

Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
@jcantrill

Copy link
Copy Markdown
Contributor

/lgtm

@jcantrill

Copy link
Copy Markdown
Contributor

/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 7, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 7, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 296d8c4 and 2 for PR HEAD 355dd57 in total

@openshift-ci

openshift-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@vparfonov: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-using-bundle 355dd57 link false /test e2e-using-bundle

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot Bot merged commit 5d1df70 into openshift:master Jul 7, 2026
9 of 10 checks passed
@vparfonov vparfonov deleted the log9562 branch July 7, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release/6.6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants