Skip to content

fix(tracing): preserve user query in suggested-question traces - #45386

Merged
41tair merged 1 commit into
langgenius:mainfrom
ZombieBlue:fix/suggested-question-trace-query
Nov 3, 2026
Merged

41tair merged 1 commit into
langgenius:mainfrom
ZombieBlue:fix/suggested-question-trace-query

Conversation

@ZombieBlue

Copy link
Copy Markdown
Contributor

Summary

Chatflow messages can have an empty model-prompt field even when their user query is persisted. Suggested-question trace assembly currently copies that empty field into the exported span input.

Keep a recorded prompt when present; otherwise fall back to the persisted query from the same tenant/app-scoped message. This read-only change preserves the generated questions, timings and correlation, without changing stored messages or provider adapters.

Fixes #45384

Validation

  • Added eight SQLite-backed regression cases covering empty string/list/object prompts, an existing prompt, and both nonempty and empty queries. They also check canonical span inputs/outputs and unchanged stored data.
  • Before the fix: 5 failed, 13 passed.
  • After the fix: 18 passed (make test TARGET_TESTS=./api/tests/unit_tests/repositories/test_trace_record_repository.py).
  • make lint passed (82 import contracts kept).
  • make type-check passed.

Checklist

  • Associated issue and scope reviewed.
  • Verified the change and added regression tests.
  • Backend lint and type checks passed.
  • No schema or documentation changes required.

From Codex

@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 83.01% 83.01% +0.00%
Strict coverage 82.66% 82.66% +0.00%
Typed symbols 85,603 85,609 +6
Untyped symbols 17,598 17,597 -1
Modules 4373 4373 0

@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.79%. Comparing base (dc36c3e) to head (a11ae6e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #45386   +/-   ##
=======================================
  Coverage   89.79%   89.79%           
=======================================
  Files        6239     6239           
  Lines      390965   390965           
  Branches    79305    79305           
=======================================
+ Hits       351077   351086    +9     
+ Misses      33788    33783    -5     
+ Partials     6100     6096    -4     
Flag Coverage Δ
api 89.64% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@41tair
41tair added this pull request to the merge queue Nov 3, 2026
Merged via the queue into langgenius:main with commit 384d1f0 Nov 3, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Chatflow suggested-question traces lose the persisted user query

2 participants