Skip to content

Commit c725a55

Browse files
[FIX] Use correct primary key in prompt studio list count subquery (#1902)
* [FIX] Use correct primary key field in prompt count subquery ToolStudioPrompt uses prompt_id as its primary key, not id. Count("id") causes FieldError on the list endpoint (500). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * [FIX] Fix ruff-format implicit string concatenation Merge adjacent f-strings into single f-string to satisfy ruff-format. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 93c0634 commit c725a55

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • backend/prompt_studio/prompt_studio_core_v2

backend/prompt_studio/prompt_studio_core_v2/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_queryset(self) -> QuerySet | None:
115115
ToolStudioPrompt.objects.filter(tool_id=OuterRef("pk"))
116116
.order_by()
117117
.values("tool_id")
118-
.annotate(cnt=Count("id"))
118+
.annotate(cnt=Count("prompt_id"))
119119
.values("cnt")
120120
)
121121
qs = qs.select_related("created_by").annotate(
@@ -1215,7 +1215,7 @@ def sync_prompts(self, request: Request, pk: Any = None) -> Response:
12151215
sync_result = PromptStudioHelper.sync_prompts(tool, import_data, request.user)
12161216
response_data.update(sync_result)
12171217
response_data["message"] = (
1218-
f"Synced {sync_result['prompts_created']} prompts " f"into '{tool.tool_name}'"
1218+
f"Synced {sync_result['prompts_created']} prompts into '{tool.tool_name}'"
12191219
)
12201220

12211221
return Response(response_data, status=status.HTTP_200_OK)

0 commit comments

Comments
 (0)