Skip to content

fix(relay): Limit maximum number of otel logs deserialized from protos - #6274

Open
klochek wants to merge 1 commit into
christopherklochek/ingest-1099-add-bounded-json-serializerfrom
christopherklochek/ingest-1100-add-bounded-proto-serializer
Open

fix(relay): Limit maximum number of otel logs deserialized from protos#6274
klochek wants to merge 1 commit into
christopherklochek/ingest-1099-add-bounded-json-serializerfrom
christopherklochek/ingest-1100-add-bounded-proto-serializer

Conversation

@klochek

@klochek klochek commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

(This points at a personal branch with which it shares a little boilerplate; will point at main when that one is merged.)

@klochek
klochek requested a review from a team as a code owner July 30, 2026 19:53
@linear-code

linear-code Bot commented Jul 30, 2026

Copy link
Copy Markdown

INGEST-1100

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit da82bf9. Configure here.

);
Error::Invalid(DiscardReason::InvalidProtobuf)
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Limit error remapped incorrectly

Medium Severity

otel_proto_deserializer::deserialize already returns logs::Error, including TooManyExpandedLogs, but parse_logs_data maps every failure to Invalid(InvalidProtobuf). Oversized protobuf payloads are still rejected, yet they surface as corrupt protobuf instead of the dedicated limit outcome.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit da82bf9. Configure here.


match merge_logs_data(&mut meter, &mut out, &mut payload, DecodeContext::default()) {
Ok(()) => Ok(out),
Err(_) if meter.is_empty() => Err(logs::Error::TooManyExpandedLogs),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: A protobuf parsing error can be misclassified as TooManyExpandedLogs if it occurs after exactly the maximum number of logs have been processed, because the error check uses meter.is_empty().
Severity: LOW

Suggested Fix

Modify the error handling to pattern-match on the specific error type returned from merge_logs_data, such as a potential Error::MeterExhausted, instead of relying on the state of the meter with meter.is_empty(). This will correctly distinguish between exceeding the log limit and a general protobuf decoding failure.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: relay-server/src/processing/logs/integrations/otel_proto_deserializer.rs#L179

Potential issue: When parsing a protobuf payload, if the payload contains exactly the
maximum number of allowed log elements followed by corrupt or truncated data, a parsing
error will be incorrectly classified. The code successfully processes all valid
elements, exhausting the `meter`. When it then fails to parse the trailing corrupt data,
the error handling logic checks `meter.is_empty()`, which is true, and incorrectly
returns `Err(logs::Error::TooManyExpandedLogs)`. The correct error should be
`Invalid(DiscardReason::InvalidProtobuf)`. This misclassification leads to incorrect
outcome tracking and metrics for invalid payloads.

Did we get this right? 👍 / 👎 to inform future reviews.

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