Skip to content

[FIX] Keep the Prompt Studio back-reference in tool registry listing; drop dead adapter-choices route#2204

Open
hari-kuriakose wants to merge 1 commit into
mainfrom
fix/registry-back-reference-dead-adapter-choices
Open

[FIX] Keep the Prompt Studio back-reference in tool registry listing; drop dead adapter-choices route#2204
hari-kuriakose wants to merge 1 commit into
mainfrom
fix/registry-back-reference-dead-adapter-choices

Conversation

@hari-kuriakose

Copy link
Copy Markdown
Contributor

What

Two small, self-contained backend bugs found during a full unstract CLI run. Anchored at 24d08728.


1. tool listing drops the back-reference to the Prompt Studio project

After export-tool there is no way to correlate a registry entry with the project that produced it. fetch_json_for_registry projects 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 are forced to match on name, which is ambiguous whenever two projects share one.

The data is already there and simply discarded. PromptStudioRegistry has a custom_tool OneToOneField pointing straight back at the project, and PromptStudioRegistrySerializer is fields = "__all__" — so custom_tool is already in pi_serializer.data. The projection just never copied it across.

This is not hypothetical — the frontend already pays for it. In CreateApiDeploymentFromPromptStudio.jsx:

tool.function_name === toolDetails.tool_id || tool.name === toolDetails.tool_name

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 — with an export-and-retry path behind it when that fails. Exposing custom_tool lets callers correlate exactly.

custom_tool is null=True, so legacy rows report None rather than failing. Additive only — no existing key changes, so nothing currently consuming this listing breaks.

2. prompt-studio/adapter-choices/ routes to a method that does not exist

Returns 500 server_error on every call.

prompt_studio_adapter_choices = PromptStudioCoreView.as_view(
    {"get": "get_adapter_choices"}
)

get_adapter_choices is not defined — not on PromptStudioCoreView, 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. I checked before choosing removal over implementation — the only two references in the entire repo were the as_view registration and the URL entry itself, and no frontend code calls it. adapter list --adapter-type LLM already filters server-side and is the working equivalent.


Verification

  • grep for adapter_choices / adapter-choices across backend/ and frontend/src returns nothing after the change.
  • urls.py parses cleanly.
  • ruff and ruff-format pass at the version pinned in .pre-commit-config.yaml (v0.3.4).

Note on tests: the Django-backed suites in these apps currently error with AppRegistryNotReady in a plain checkout, and the prompt_studio_core_v2 tests skip without test.env. A test written in that style would silently skip and read as coverage that isn't there. Happy to add one if there's a documented way to run those suites in CI.

Impact

  • tool registry list can offer real tool_id filtering, and the frontend's dead first clause can be replaced with a correct comparison in a follow-up.
  • A dead endpoint stops returning 500.

🤖 Generated with Claude Code

… 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>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 99c6d782-815f-4d65-850a-7fc4ea22a2db

📥 Commits

Reviewing files that changed from the base of the PR and between 023b140 and ea7654e.

📒 Files selected for processing (3)
  • backend/prompt_studio/prompt_studio_core_v2/urls.py
  • backend/prompt_studio/prompt_studio_registry_v2/constants.py
  • backend/prompt_studio/prompt_studio_registry_v2/prompt_studio_registry_helper.py
💤 Files with no reviewable changes (1)
  • backend/prompt_studio/prompt_studio_core_v2/urls.py

Summary by CodeRabbit

  • New Features

    • Tool metadata now includes a custom tool identifier, improving association with Prompt Studio projects.
  • Breaking Changes

    • Removed the Prompt Studio adapter-choices endpoint from the available API routes.

Walkthrough

The changes remove the Prompt Studio adapter-choices endpoint and add a custom_tool schema key whose value is included in registry tool metadata.

Changes

Registry custom-tool metadata

Layer / File(s) Summary
Custom-tool registry metadata
backend/prompt_studio/prompt_studio_registry_v2/constants.py, backend/prompt_studio/prompt_studio_registry_v2/prompt_studio_registry_helper.py
Adds JsonSchemaKey.CUSTOM_TOOL and includes the corresponding serialized value in each tool metadata entry.

Adapter-choices route removal

Layer / File(s) Summary
Remove adapter-choices endpoint
backend/prompt_studio/prompt_studio_core_v2/urls.py
Removes the DRF view binding and URL pattern for prompt-studio/adapter-choices/.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: harini-venkataraman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: preserving the Prompt Studio back-reference and removing the dead adapter-choices route.
Description check ✅ Passed The description covers what changed, why, how, breakage impact, and testing/verification; only some optional template sections are omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/registry-back-reference-dead-adapter-choices

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves Prompt Studio registry correlation and removes a nonfunctional endpoint.

  • Adds the source Prompt Studio project ID to flattened tool-registry listing entries.
  • Defines the corresponding custom_tool schema key.
  • Removes the dead prompt-studio/adapter-choices/ route whose configured view action did not exist.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness or security issues identified.

The new listing field uses the registry model’s existing nullable one-to-one reference to expose the source tool identifier, while the removed route had no implemented action or repository consumers.

Important Files Changed

Filename Overview
backend/prompt_studio/prompt_studio_core_v2/urls.py Removes an unreferenced route bound to a nonexistent view action, replacing an unconditional server error with an honest 404.
backend/prompt_studio/prompt_studio_registry_v2/constants.py Adds the custom_tool key used to expose the source Prompt Studio project identifier.
backend/prompt_studio/prompt_studio_registry_v2/prompt_studio_registry_helper.py Additively includes the serialized source-project back-reference in each flattened Prompt Studio registry entry.

Reviews (1): Last reviewed commit: "[FIX] Keep the Prompt Studio back-refere..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Unstract test results

Per-group results

Status Group Tier Passed Failed Errors Skipped Duration (s)
e2e-api-deployment e2e 3 0 0 0 16.6
e2e-coowners e2e 1 0 0 0 1.4
e2e-etl e2e 1 0 0 0 8.8
e2e-login e2e 2 0 0 0 1.3
e2e-prompt-studio e2e 1 0 0 0 5.1
e2e-smoke e2e 2 0 0 0 1.5
e2e-workflow e2e 1 0 0 0 18.5
integration-backend integration 162 0 0 26 41.6
integration-connectors integration 1 0 0 7 7.9
integration-workers integration 0 0 0 141 99.8
unit-backend unit 277 0 0 1 28.9
unit-connectors unit 63 0 0 0 8.2
unit-core unit 33 0 0 0 1.0
unit-platform-service unit 15 0 0 0 2.6
unit-rig unit 86 0 0 0 3.9
unit-sdk1 unit 480 0 0 0 22.1
unit-workers unit 1312 0 0 0 89.0
TOTAL 2440 0 0 175 358.4

Critical paths

⚠️ Critical paths not yet covered

  • workflow-execution-fan-out — Multi-file workflow execution fans out to file-processing workers and rejoins. (declared coverage: no groups declared)
✅ Covered critical paths
  • auth-login — covered by e2e-login
  • adapter-register-llm — covered by integration-backend
  • workflow-author — covered by integration-backend
  • co-owner-manage — covered by integration-backend, e2e-coowners
  • workflow-create-execute — covered by e2e-workflow
  • api-deployment-provision — covered by integration-backend
  • api-deployment-auth — covered by integration-backend
  • api-deployment-run — covered by e2e-api-deployment
  • prompt-studio-author — covered by integration-backend
  • prompt-studio-fetch-response — covered by e2e-prompt-studio
  • connector-register-test — covered by integration-backend
  • pipeline-etl-execute — covered by e2e-etl
  • usage-aggregate-read — covered by integration-backend
  • usage-token-tracking — covered by e2e-api-deployment
  • callback-result-delivery — covered by e2e-api-deployment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant