UN-2946 [MISC] Fix empty Default tab in Prompt Studio Combined Output#1956
UN-2946 [MISC] Fix empty Default tab in Prompt Studio Combined Output#1956chandrasekharan-zipstack wants to merge 1 commit into
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 |
|
Test ResultsSummary
Runner Tests - Full Report
SDK1 Tests - Full Report
|
|
| Filename | Overview |
|---|---|
| backend/prompt_studio/prompt_studio_output_manager_v2/output_manager_helper.py | One-line fix: replaces o.prompt_id (returns a ToolStudioPrompt instance due to FK field name shadowing the PK) with o.prompt_id_id (raw UUID column) when building the outputs_index lookup dictionary. |
Sequence Diagram
sequenceDiagram
participant C as Client
participant H as OutputManagerHelper
participant DB as Database (Postgres)
participant IDX as outputs_index dict
C->>H: fetch_default_output_response(tool_studio_prompts, doc_id)
H->>H: resolve default profile per prompt → prompts_to_query
H->>DB: DISTINCT ON (prompt_id, profile_manager_id) query
DB-->>H: QuerySet of PromptStudioOutputManager rows
Note over H,IDX: BEFORE fix: str(o.prompt_id) → "ToolStudioPrompt object (<uuid>)"
Note over H,IDX: AFTER fix: str(o.prompt_id_id) → "xxxxxxxx-xxxx-…" (raw UUID)
H->>IDX: "build {(prompt_uuid, profile_uuid): output_row}"
loop for each tool_prompt in prompts_to_query
H->>IDX: get((str(tool_prompt.prompt_id), profile_manager_id))
IDX-->>H: output row (or None)
H->>H: "result[prompt_key] = output.output"
end
H-->>C: "{prompt_key: value, …}"
Reviews (1): Last reviewed commit: "[MISC] [FIX] Fix empty Default tab in Pr..." | Re-trigger Greptile



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.