Skip to content

feat(core): Require attributes on SerializedStreamedSpan#22052

Merged
mydea merged 1 commit into
developfrom
feat/required-streamed-span-attributes
Jul 8, 2026
Merged

feat(core): Require attributes on SerializedStreamedSpan#22052
mydea merged 1 commit into
developfrom
feat/required-streamed-span-attributes

Conversation

@Lms24

@Lms24 Lms24 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Make attributes a required field on SerializedStreamedSpan so tests and downstream code can rely on it always being present, without optional chaining.

Production code already guarantees this: streamedSpanJsonToSerializedSpan always sets attributes via serializeAttributes(), which returns {} when the intermediate StreamedSpanJSON has no attributes. Only test mocks needed updating to include attributes: {}.

We likely can adjust the StreamedSpanJson type in a similar way to gain some production code benefits as well. Gonna look at this in a follow-up

@Lms24 Lms24 changed the title ref(core): Require attributes on SerializedStreamedSpan feat(core): Require attributes on SerializedStreamedSpan Jul 8, 2026
@Lms24 Lms24 changed the title feat(core): Require attributes on SerializedStreamedSpan feat(core): Require attributes on SerializedStreamedSpan Jul 8, 2026
@Lms24 Lms24 self-assigned this Jul 8, 2026
Make attributes a required field on the final serialized span type so
tests can rely on it always being present. Production code already
guarantees this via serializeAttributes returning an empty object.

Co-Authored-By: Cursor <cursoragent@cursor.com>
@mydea
mydea force-pushed the feat/required-streamed-span-attributes branch from 509ce9d to 9f80421 Compare July 8, 2026 11:34
@mydea
mydea merged commit db315a5 into develop Jul 8, 2026
588 of 590 checks passed
@mydea
mydea deleted the feat/required-streamed-span-attributes branch July 8, 2026 12:47
mydea added a commit that referenced this pull request Jul 8, 2026
The `suites/**` test files in `node-integration-tests` were never
type-checked, so type errors only ever surfaced in the editor — never in
CI. This adds a CI gate that type-checks the suites and fixes the ~2000
latent errors it surfaced.

## Root cause

- `yarn type-check` runs a bare `tsc`, whose `tsconfig.json` only
includes `utils/**` and `src/**` — not `suites/**`.
- `yarn test` (vitest) transpiles with esbuild, which strips types
without checking them.

With nothing exercising the suite types, errors accumulated silently.

## Changes

- Add `type-check:src` / `type-check:test` scripts (both `--noEmit`, so
a bare run can't scatter `.js` next to sources) and run `yarn
type-check` for the package in the **Lint** CI job.
- Relax `noUncheckedIndexedAccess` for test code — indexing into span
attributes/arrays that are known to exist at that point shouldn't
require `!` everywhere — and exclude the Prisma CLI config, whose
runtime shape intentionally differs from `@prisma/config`'s exported
types.
- Give `createTestServer` an explicit return type so chained `.get()`
calls infer their `headers` callback parameter (previously only the
first `.get()` was typed).
- Add a `getStringAttributeValue` helper to narrow union-typed span
attribute values in the AI tracing assertions (`includes` / `startsWith`
/ `match` / `length`).
- Fix the vitest reporter config to the valid nested-tuple form.

All changes are type-level / test-scoped and runtime-transparent.

---

Stacked on top of #22052, which makes `attributes` required on
`SerializedStreamedSpan` — merge that one first.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mydea added a commit that referenced this pull request Jul 8, 2026
…lizedStreamedSpan` objects (#22060)

Adjusts tests to avoid checking for definedness on
`SerializedStreamedSpan` `attributes` (following #22052)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
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.

2 participants