pierrejeambrun commented on code in PR #44322:
URL: https://github.com/apache/airflow/pull/44322#discussion_r1860592961


##########
tests/api_fastapi/core_api/routes/public/test_connections.py:
##########
@@ -235,9 +235,7 @@ def test_post_should_respond_already_exist(self, 
test_client, body):
         # Another request
         response = test_client.post("/public/connections/", json=body)
         assert response.status_code == 409
-        assert response.json() == {
-            "detail": f"Connection with connection_id: `{TEST_CONN_ID}` 
already exists",
-        }
+        assert response.json() == {"detail": "Unique constraint violation"}

Review Comment:
   Regexp can be not super reliable, also it will depends on the error message 
of the database (which can change between releases and versions).
   
   Maybe just returning the `orig ` field as the message is a good start. I 
find the message self explanatory. (A bit technical, but easy to grasp that a 
conflict on a specific field is happening). We can always improve / refine 
later.
   
   edit: But that will be a problem for testing. As the message change 
depending on backend used...
   
   edit2: Also returning direct message from the db can be a little sketchy, we 
don't know what information will be returned to the user in advance and some 
parameters values could come from the server side, exposing them in the 
response...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to