Skip to content

app/vlinsert/loki: handle empty structured metadata - #1757

Open
jwmay2012 wants to merge 2 commits into
VictoriaMetrics:masterfrom
jwmay2012:fix/loki-empty-structured-metadata
Open

app/vlinsert/loki: handle empty structured metadata#1757
jwmay2012 wants to merge 2 commits into
VictoriaMetrics:masterfrom
jwmay2012:fix/loki-empty-structured-metadata

Conversation

@jwmay2012

Copy link
Copy Markdown

Grafana Alloy can send structured metadata whose extracted value is empty. Loki's LabelPairAdapter uses implicit-presence proto3 string fields, so generated encoders do not serialize name or value when the corresponding string is empty. VictoriaLogs currently treats that normal proto3 omission as malformed and rejects the complete push with missing name or missing value.

The resulting error is:

cannot decode PushRequest: cannot unmarshal Stream: cannot unmarshal Entry: cannot unmarshal StructuredMetadata: missing value

This appears to be an unintended side effect of the streaming protobuf parser optimization, released in v1.40.0. A sibling OpenTelemetry decoder introduced by the same optimization pattern was subsequently changed to skip attributes with omitted keys rather than reject the request. The Loki decoder already intentionally ignores a metadata pair after decoding when either its name or value is empty.

Treat omitted fields as their empty-string defaults and continue ignoring metadata pairs unless both values are non-empty. Malformed encoded fields still return errors.

Adds an end-to-end protobuf regression test covering an omitted name, an omitted value, an empty pair, and a valid pair in the same request, plus a changelog entry.

Tested with:

  • go test ./app/vlinsert/loki -count=1
  • make check-all
  • make test-full
  • make apptest

@jwmay2012
jwmay2012 marked this pull request as ready for review September 1, 2026 15:48

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/victorialogs/CHANGELOG.md">

<violation number="1" location="docs/victorialogs/CHANGELOG.md:38">
P3: This new BUGFIX entry has no references link, unlike every other FEATURE/BUGFIX line in the changelog, which ends with a `See [#NNNN](...)` link (e.g. lines 39-41, or line 293 for the prior Loki ingestion fix). Add a references link using the current PR as the reference.</violation>
</file>

Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.

Re-trigger cubic

Comment thread docs/victorialogs/CHANGELOG.md Outdated
@jwmay2012
jwmay2012 force-pushed the fix/loki-empty-structured-metadata branch from 6bd1263 to 4340ec7 Compare September 1, 2026 15:58

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread docs/victorialogs/CHANGELOG.md Outdated
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Signed-off-by: Jordan May <jwmay2012@gmail.com>
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.

1 participant