UN-2946 [MISC] Fix empty Default tab in Prompt Studio Combined Output#1956
Conversation
The DISTINCT-ON refactor in fetch_default_output_response built the outputs_index with str(o.prompt_id), but PromptStudioOutputManager names its FK field ``prompt_id`` (shadowing the PK column ``prompt_id_id``), so ``o.prompt_id`` returns the related ToolStudioPrompt instance, not a UUID. ``str()`` on the instance produces ``"ToolStudioPrompt object (<uuid>)"``, which never matches the canonical-UUID lookup keys — every prompt resolved to "" and the Default tab rendered as an empty payload. Use ``prompt_id_id`` for the index key. Side benefit: no N+1 from lazy loading the related instance per row, which was the perf intent of the original commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
WalkthroughIn ChangesFK Field Access Correction
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
|
| Filename | Overview |
|---|---|
| backend/prompt_studio/prompt_studio_output_manager_v2/output_manager_helper.py | One-line fix: o.prompt_id_id (raw FK column) replaces o.prompt_id (which resolved to a ToolStudioPrompt instance) in the outputs_index key, correctly restoring Default tab output. |
Sequence Diagram
sequenceDiagram
participant UI as Combined Output UI
participant API as fetch_default_output_response
participant DB as PromptStudioOutputManager (DB)
UI->>API: GET Default tab (tool_studio_prompts, document_manager_id)
API->>API: _resolve each prompt → profile_manager_id (UUID string)
API->>DB: DISTINCT ON (prompt_id, profile_manager_id) query
DB-->>API: QuerySet of PromptStudioOutputManager rows
note over API: BEFORE fix: str(o.prompt_id) returns<br/>ToolStudioPrompt instance string<br/>→ dict key never matches → result is empty
note over API: AFTER fix: str(o.prompt_id_id) returns<br/>raw UUID FK column value<br/>→ dict key matches correctly
API->>API: Build outputs_index keyed by (prompt_uuid, profile_uuid)
API->>API: Lookup each prompt output from index
API-->>UI: Return populated result dict
Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/combined-ou..." | Re-trigger Greptile
|
Test ResultsSummary
Runner Tests - Full Report
SDK1 Tests - Full Report
|



What
Why
DISTINCT-ONrefactor infetch_default_output_response(commit993ae95d1, merged via PR UN-2946 [FEAT] Prompt Studio lookups bridge, executor hook, and IDE wiring (OSS side) #1929) builtoutputs_indexwithstr(o.prompt_id).PromptStudioOutputManagerthe FK field is namedprompt_id, which shadows the related model's PK column — soo.prompt_idreturns theToolStudioPromptinstance, not a UUID.str()on the instance produces"ToolStudioPrompt object (<uuid>)", never matches the canonical-UUID lookup key, and every prompt resolves to""→ Default tab renders empty.da2b94a4-6f0d-4919-8fcf-6ee160d32ff1, doccb966b88-…): the row for promptskillson the tool's default profile has 59 chars of output, but the Default tab payload returns{skills: "", summary: ""}. Matches the user's screenshot exactly.How
str(o.prompt_id)→str(o.prompt_id_id)in theoutputs_indexdict comprehension.prompt_id_idis the raw FK column.ToolStudioPromptper row, restoring the perf intent of the original commit.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
listwithprofile_manager=filter) and are unaffected. SinglePass Extraction mode is unaffected — its data path is keyed offdefaultLlmProfilerather thanfetch_default_output_response.Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
993ae95d1[PERF] Push Combined Output queries into SQL.Dependencies Versions
Notes on Testing
profile_manager_id(or none, falling back to the tool's default LLM profile).Screenshots
{skills: "", summary: ""}before fix).Checklist
I have read and understood the Contribution Guidelines.