Skip to content

fix: normalize Source to service name for Claude Code tool call messages#2335

Merged
bradcypert merged 3 commits intomainfrom
bradcypert/normalize-claude-code-source
Apr 21, 2026
Merged

fix: normalize Source to service name for Claude Code tool call messages#2335
bradcypert merged 3 commits intomainfrom
bradcypert/normalize-claude-code-source

Conversation

@bradcypert
Copy link
Copy Markdown
Contributor

Why

The PreToolUse and PostToolUse handlers hardcoded "ClaudeCode" while the UserPromptSubmit/Stop handler used metadata.ServiceName ("claude-code"), causing split values in the chat_messages.Source column for the same session.

What changed

Use metadata.ServiceName consistently across all four writes.

Before

We were tracking both "ClaudeCode" and "claude-code" (from the service-name)

After

Just "claude-code"

The PreToolUse and PostToolUse handlers hardcoded "ClaudeCode" while the
UserPromptSubmit/Stop handler used metadata.ServiceName ("claude-code"),
causing split values in the chat_messages.Source column for the same
session. Use metadata.ServiceName consistently across all four writes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bradcypert bradcypert requested a review from a team as a code owner April 21, 2026 14:32
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gram-docs-redirect Ready Ready Preview, Comment Apr 21, 2026 2:45pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: cbf2930

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
server Patch

Not sure what this means? Click here to learn what changesets are.

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

@adaam2
Copy link
Copy Markdown
Member

adaam2 commented Apr 21, 2026

Add a test?

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pins the invariant that all chat_messages rows produced by a single
Claude Code session carry the same Source value. Exercises all four
write paths (UserPromptSubmit/Stop/PreToolUse/PostToolUse/PostToolUseFailure)
against a real Postgres test DB and asserts each row's Source matches
metadata.ServiceName.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bradcypert bradcypert merged commit afe4b80 into main Apr 21, 2026
26 checks passed
@bradcypert bradcypert deleted the bradcypert/normalize-claude-code-source branch April 21, 2026 15:00
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants