Skip to content

fix(sentry): accept ISO timestamps and non-string span data in nested items - #349

Draft
tsan88 wants to merge 1 commit into
buggregator:masterfrom
tsan88:fix/sentry-nested-flexible-timestamps
Draft

fix(sentry): accept ISO timestamps and non-string span data in nested items#349
tsan88 wants to merge 1 commit into
buggregator:masterfrom
tsan88:fix/sentry-nested-flexible-timestamps

Conversation

@tsan88

@tsan88 tsan88 commented Sep 4, 2026

Copy link
Copy Markdown

Envelopes were being dropped on parse, with the SDK still getting HTTP 200.

Nested envelope structures declared their timestamps as json.Number, while the top-level ErrorEvent already used FlexibleTS. PHP/Laravel SDKs put ISO 8601 strings into breadcrumbs, transactions, spans and logs, so unmarshalling failed with

invalid number literal, trying to unmarshal "2026-09-03T11:04:16.035Z" into Number

and the whole event was discarded.

RawSpan.Data had the same class of problem: declared map[string]string, but SDKs put numbers and booleans there (http.response.status_code: 200), which failed with

cannot unmarshal number into Go struct field RawSpan.spans.data of type string

and dropped the transaction together with all of its spans.

Measured on a production instance before the fix, over one hour: of 1326 envelopes accepted by the proxy for one PHP project, only 62 reached the database. A second project got 135 events in and stored none at all.

Changes

  • Breadcrumb, Transaction, RawSpan and LogRecord timestamps use FlexibleTS, the type this repo already has for exactly this.
  • Span attributes go through a new SpanData type that normalizes values to strings, so classifySpan, extractServiceName and the spans table stay unchanged. Objects and arrays keep their raw JSON instead of being lost.

Testing

go vet ./..., go test ./... and go build pass. Added regression tests for both shapes (TestFlexibleTS_NestedStructures, TestSpanData_AcceptsNonStringValues). Running in production on our instance since 2026-09-03.

… items

Nested envelope structures declared their timestamps as json.Number while the
top-level ErrorEvent already used FlexibleTS. PHP/Laravel SDKs send ISO 8601
strings in breadcrumbs, transactions, spans and logs, so unmarshalling failed
with "invalid number literal, trying to unmarshal ... into Number" and the
entire event was dropped (the request still answered 200).

RawSpan.Data had the same class of problem: declared map[string]string, but SDKs
put numbers and booleans there (http.response.status_code: 200), which failed
with "cannot unmarshal number into Go struct field RawSpan.spans.data of type
string" and dropped the transaction with all of its spans.

Measured on a production stream before the fix: of 1326 envelopes accepted by
the proxy for one PHP project only 62 reached the database.

Breadcrumb, Transaction, RawSpan and LogRecord now use FlexibleTS, and span
attributes go through a SpanData type that normalizes values to strings, so
existing consumers stay unchanged.
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