diff --git a/src/phoenix/server/api/mutations/prompt_mutations.py b/src/phoenix/server/api/mutations/prompt_mutations.py index 038dac1e6b1..2ec83df94b3 100644 --- a/src/phoenix/server/api/mutations/prompt_mutations.py +++ b/src/phoenix/server/api/mutations/prompt_mutations.py @@ -247,11 +247,9 @@ async def clone_prompt(self, info: Info[Context, None], input: ClonePromptInput) new_prompt.prompt_versions = new_versions session.add(new_prompt) - await session.flush() try: await session.commit() except (PostgreSQLIntegrityError, SQLiteIntegrityError): raise Conflict(f"A prompt named '{input.name}' already exists") - return to_gql_prompt_from_orm(new_prompt) diff --git a/tests/unit/server/api/mutations/test_prompt_mutations.py b/tests/unit/server/api/mutations/test_prompt_mutations.py index 7412b51f2fd..f6b598f3f66 100644 --- a/tests/unit/server/api/mutations/test_prompt_mutations.py +++ b/tests/unit/server/api/mutations/test_prompt_mutations.py @@ -976,5 +976,8 @@ async def test_clone_prompt_fails_with_duplicate_name( # clone prompt result = await gql_client.execute(self.CLONE_PROMPT_MUTATION, variables) assert len(result.errors) == 1 - assert "UNIQUE constraint failed: prompts.name" in result.errors[0].message + assert ( + f"A prompt named '{variables['input']['name']}' already exists" + in result.errors[0].message + ) assert result.data is None