Skip to content

fix(trace): LangSmith trace_id mismatch in chatflow workflow traces#35979

Merged
fatelei merged 1 commit into
langgenius:mainfrom
ki3nd:fix/langsmith-trace-id-mismatch
May 11, 2026
Merged

fix(trace): LangSmith trace_id mismatch in chatflow workflow traces#35979
fatelei merged 1 commit into
langgenius:mainfrom
ki3nd:fix/langsmith-trace-id-mismatch

Conversation

@ki3nd
Copy link
Copy Markdown
Contributor

@ki3nd ki3nd commented May 9, 2026

In workflow_trace(), trace_id was set from trace_info.trace_id (external trace ID from X-Trace-Id header) before falling back to message_id. When an external trace_id is present and differs from message_id, LangSmith rejects the batch with HTTP 400 because trace_id must equal the first UUID in dotted_order (which is always the root run's run_id).

Fix: derive trace_id from the root run's actual run_id — message_id for chatflows, workflow_run_id for pure workflows. The external trace_id is preserved in metadata for cross-system correlation.

Fixes: #35972

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

In workflow_trace(), trace_id was set from trace_info.trace_id (external
trace ID from X-Trace-Id header) before falling back to message_id. When
an external trace_id is present and differs from message_id, LangSmith
rejects the batch with HTTP 400 because trace_id must equal the first UUID
in dotted_order (which is always the root run's run_id).

Fix: derive trace_id from the root run's actual run_id — message_id for
chatflows, workflow_run_id for pure workflows. The external trace_id is
preserved in metadata for cross-system correlation.

Fixes: langgenius#35972
@ki3nd ki3nd requested a review from QuantumGhost as a code owner May 9, 2026 12:49
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 43.67% +43.67%
Strict coverage 0.00% 43.20% +43.20%
Typed symbols 0 21,962 +21,962
Untyped symbols 0 28,637 +28,637
Modules 0 2547 +2,547

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 11, 2026
@fatelei fatelei added this pull request to the merge queue May 11, 2026
Merged via the queue into langgenius:main with commit bf117dd May 11, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] LangSmith tracing fails with 400 "trace_id does not match first part of dotted_order" in Chatflow conversations

2 participants