[FIX] Keep the Prompt Studio back-reference in tool registry listing; drop dead adapter-choices route#2204
Conversation
… drop dead adapter-choices route
1. `tool` listing dropped the link back to the Prompt Studio project
After `export-tool` there was no way to correlate a registry entry with the
project that produced it. `fetch_json_for_registry` projected only four keys -
`name`, `description`, `icon`, `function_name` - where `function_name` is the
`prompt_registry_id`, a fresh UUID, not the Prompt Studio `tool_id`. Callers
were left matching on `name`, which is ambiguous whenever two projects share
one.
The data was already there and simply discarded: `PromptStudioRegistry` has a
`custom_tool` OneToOneField pointing straight back at the project, and the
serializer is `fields = "__all__"`, so it is already present in the serialized
data. The listing now carries it.
The frontend shows the cost of the omission today:
tool.function_name === toolDetails.tool_id || tool.name === toolDetails.tool_name
The first clause can never match (a registry UUID is compared against a Prompt
Studio tool_id), so correlation silently falls through to the ambiguous name
comparison. With `custom_tool` exposed, callers can correlate exactly.
`custom_tool` is `null=True`, so legacy rows report `None` rather than failing.
Additive only - no existing key changes.
2. `prompt-studio/adapter-choices/` routed to a method that does not exist
The URL mapped `get` to `get_adapter_choices`, which is not defined on
`PromptStudioCoreView` or anywhere else in the backend. The route resolved, the
handler was missing, and every request returned 500 `server_error`.
Removed the route and its `as_view` registration so the path 404s honestly
instead of 500ing. Verified there are no other references: the only two in the
repo were the route registration and the URL entry, and no frontend code calls
it. `adapter list --adapter-type LLM` already covers this server-side.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
WalkthroughThe changes remove the Prompt Studio adapter-choices endpoint and add a ChangesPrompt Studio registry and routing
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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_core_v2/urls.py | Removes the route and registration for an undefined, unreferenced adapter-choices action. |
| backend/prompt_studio/prompt_studio_registry_v2/constants.py | Adds the constant used to project the Prompt Studio project back-reference. |
| backend/prompt_studio/prompt_studio_registry_v2/prompt_studio_registry_helper.py | Adds the source CustomTool identifier to each user-scoped Prompt Studio registry-list entry. |
| backend/prompt_studio/prompt_studio_registry_v2/tests/test_fetch_json_for_registry.py | Adds regression tests covering the back-reference, existing fields, nullable legacy rows, and duplicate project names. |
Reviews (2): Last reviewed commit: "[TEST] Pin the Prompt Studio back-refere..." | Re-trigger Greptile
Regression tests for the `custom_tool` projection added in this PR.
Exercises the real `fetch_json_for_registry` body, stubbing only the
ORM/serializer boundary, since the function is a pure projection over
already-serialized rows. Django is not importable in a plain checkout, so the
body is extracted from source - mirroring
`prompt_studio_core_v2/tests/test_build_index_payload.py`.
Coverage:
- the listing carries `custom_tool` (the Prompt Studio tool_id)
- `function_name` remains the registry UUID and is distinct from
`custom_tool`, pinning the distinction that made the back-reference
necessary and guarding against "fixing" the frontend's dead comparison by
redefining `function_name` instead
- existing keys are preserved, so the change stays additive
- an unlinked legacy row (`custom_tool` is nullable) reports None rather than
raising, and is not dropped
- rows do not bleed into each other: the loop reuses one dict and resets it
per row, and a missing reset would smear one project's back-reference onto
the next - callers would then correlate confidently and wrongly
- two projects sharing a name stay distinguishable, which is the scenario the
old four-key projection could not represent
Verified by mutation: removing the `custom_tool` projection fails five of the
six tests, with the sixth (existing-keys) correctly unaffected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Unstract test resultsPer-group results
Critical paths
|



Purpose
Fixes two small, self-contained backend bugs in the tool registry surface.
1. Registry listing drops the back-reference to the Prompt Studio project
There is no way to correlate a registry entry with the project that produced it.
fetch_json_for_registryprojects only four keys —name,description,icon,function_name— wherefunction_nameis theprompt_registry_id, a fresh UUID, not the Prompt Studiotool_id. Callers are forced to match onname, which is ambiguous whenever two projects share one.The data is already present and simply discarded:
PromptStudioRegistryhas acustom_toolOneToOneFieldpointing back at the project, andPromptStudioRegistrySerializerisfields = "__all__", socustom_toolis already inpi_serializer.data. The projection just never copied it across.The frontend already pays for the omission. In
CreateApiDeploymentFromPromptStudio.jsx:The first clause can never be true (a registry UUID compared against a Prompt Studio
tool_id), so correlation silently falls through to the ambiguous name comparison. Exposingcustom_toollets callers correlate exactly.custom_toolisnull=True, so legacy rows reportNonerather than failing. Additive only — no existing key changes, so nothing consuming this listing breaks.2.
prompt-studio/adapter-choices/routes to a method that does not existReturns
500 server_erroron every call.get_adapter_choicesis not defined — not onPromptStudioCoreView, not anywhere in the backend. The route resolves, the handler is missing, every request 500s.Fix: remove it, so the path 404s honestly instead of 500ing. The only two references in the repo were the
as_viewregistration and the URL entry itself, and no frontend code calls it. Listing LLM adapters is already available server-side via the adapter list endpoint filtered by type.Verification
adapter_choices/adapter-choicesreturns nothing after the change.urls.pyparses cleanly.ruffandruff-formatpass at the version pinned in.pre-commit-config.yaml(v0.3.4).Impact
tool_idfiltering, and the frontend's dead first clause can be replaced with a correct comparison in a follow-up.Related
Part of a set of independent Prompt Studio / registry fixes: #2203 (profile fallback + challenge-off deploy), #2206 (registry delete + API-key ergonomics), #2209 (challenge-on deploy). No code dependency between them.
🤖 Generated with Claude Code