Skip to content

fix(webapp): preserve colons in session-stream span session keys - #5161

Closed
ghazy2001 wants to merge 1 commit into
triggerdotdev:mainfrom
ghazy2001:fix/session-stream-colon-key-5160
Closed

ghazy2001 wants to merge 1 commit into
triggerdotdev:mainfrom
ghazy2001:fix/session-stream-colon-key-5160

Conversation

@ghazy2001

Copy link
Copy Markdown

Closes #5160

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Testing

  • Added unit tests in �pps/webapp/test/sessionStreamEntity.test.ts covering:
    • out spans with colons in the session key (e.g., clerk:user_123:v2, with and without channels)
    • in spans (${runId}:::in) ensuring
      unId is never merged into sessionId
    • Session keys starting with
      un_ when resolved from span properties
    • properties-only spans when entityId is omitted
    • entityId fallback parsing when properties are absent
    • Invalid io values and missing/empty session IDs returning
      ull
  • Verified locally from �pps/webapp:

ode ../../node_modules/vitest/vitest.mjs run test/sessionStreamEntity.test.ts (7 passed)

  • oxlint (0 warnings, 0 errors across the 3 changed files)
  • oxfmt --check (all matched files formatted)
  • knip -W apps/webapp --include files,exports,types (exit 0)

Changelog

Previously, SpanPresenter parsed session-stream entities by splitting span.entity.id on : and indexing parts.at(-3) as sessionId, truncating session keys that contain : (such as clerk:user_XXXX:v2) and causing dashboard session-stream requests to 404.

Additionally, in stream spans include a leading ${runId}: prefix in entityId (${runId}:::in), whereas out spans use ${sessionId}::out.

extractSessionStreamEntity in �pps/webapp/app/presenters/v3/sessionStreamEntity.ts now prefers the unsplit session, channel, and io attributes on span.properties (emitted by both in and out session-stream spans), and falls back to entityId parsing that handles both out and ${runId}:-prefixed in formats.


Screenshots

N/A

@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 824ba82

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Hi @ghazy2001, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devin-ai-integration devin-ai-integration 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.

Devin Review found 3 potential issues.

Devin Review

Comment on lines +31 to +41
const propSessionId =
typeof props?.session === "string" && props.session.length > 0 ? props.session : undefined;
const propIo = props?.io === "out" || props?.io === "in" ? props.io : undefined;
const propChannel =
typeof props?.channel === "string" && props.channel.length > 0 ? props.channel : undefined;

let sessionId = propSessionId;
let io: string | undefined = propIo;
let channel = propChannel;

if (!sessionId || !io) {

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.

🟡 Redacted spans break stream playback

When a span processor masks a session key, extractSessionStreamEntity uses the masked key for playback. UserSpanProcessorWrapper preserves the original entity ID, which previously supplied the key. The dashboard requests a session that does not exist.

Learn more

A session-stream span carries its address both in an internal entity ID and in public telemetry attributes, as shown in the output stream emitter. Projects can install a span processor that masks emails before those attributes reach the dashboard. UserSpanProcessorWrapper restores the internal ID but leaves the public attributes redacted. SpanEntity uses the extracted address to open the stream, so refreshing does not help.

Example: A task writes to the default output stream for alex@example.com. The documented email scrubber changes the public session attribute to [email] but leaves the entity ID as alex@example.com::out. The previous viewer opened the existing stream; the new viewer requests [email] and gets a 404 unless a session exists under that placeholder.

Recommended fix: Make the protected entity ID authoritative for current-format stream addresses, parsing the direction and channel from the right and removing the input run prefix. Use public attributes only for formats where they are needed to disambiguate the protected ID, or where the ID is absent. Add a regression case with a scrubbed public session attribute and an intact entity ID.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +76 to +91
it("resolves session stream fields from properties when entityId is absent", () => {
expect(
extractSessionStreamEntity({
entityId: undefined,
properties: {
session: "user:abc:def",
io: "in",
},
})
).toEqual({
sessionId: "user:abc:def",
channel: undefined,
io: "in",
metadata: undefined,
});
});

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.

🔍 Properties-only test bypasses storage gate

getSpan requires an entity ID before it emits a ClickHouse span entity. The helper test does not cover what the dashboard receives when that ID is missing.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +954 to +958
const sessionStream = extractSessionStreamEntity({
entityId: span.entity.id,
entityMetadata: span.entity.metadata,
properties: span.properties,
});

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.

🔍 Missing dashboard fix release note

The dashboard fix is user-facing and server-only, but the PR omits the required server release note.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Dashboard: session-stream span 404s when the session key contains ':'

1 participant