Bump kafka schemas#337
Merged
Merged
Conversation
bmckerry
approved these changes
Jun 25, 2026
untitaker
approved these changes
Jun 25, 2026
untitaker
left a comment
Member
There was a problem hiding this comment.
something weird is going on in the uv lockfile. why are so many transient deps bumped?
| self.spans_list.append(value.payload) | ||
| self.total_duration += value.payload["duration_ms"] | ||
| span = value.payload | ||
| duration_ms = int((span["end_timestamp"] - span["start_timestamp"]) * 1000) |
There was a problem hiding this comment.
Bug: A KeyError may occur when calculating span duration, as start_timestamp or end_timestamp might be missing from the span data. The code lacks defensive checks.
Severity: HIGH
Suggested Fix
Verify that start_timestamp and end_timestamp are guaranteed to be present in all ingest_spans_v1.SpanEvent messages. If they can be missing, add defensive code to handle their absence, such as using the .get() method with a default value or wrapping the calculation in a try-except KeyError block to safely handle incomplete spans.
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: sentry_streams/sentry_streams/examples/span_helpers.py#L45
Potential issue: The code calculates span duration by directly accessing
`span["end_timestamp"]` and `span["start_timestamp"]`. This calculation assumes both
keys are always present in span data from the `ingest_spans_v1` schema. However, raw
ingestion data may not always include these fields, for example, in the case of
in-progress spans. If a span is processed that is missing either of these keys, the
application will raise a `KeyError`, which could crash the message processing pipeline.
The code does not include any error handling or checks to prevent this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unfortunately we need to bump the library to update schemas as we have not done this
https://linear.app/getsentry/issue/STREAM-107/decouple-sentry-stream-from-sentry-kafka-schemas