fix: preserve API prefix in session Location header (fixes #247)#248
fix: preserve API prefix in session Location header (fixes #247)#248Flamki wants to merge 2 commits intojenkinsci:mainfrom
Conversation
| @@ -11,6 +17,20 @@ def test_start_chat(client, mock_init_session): | |||
| assert response.headers["location"] == "/sessions/test-session-id/message" | |||
There was a problem hiding this comment.
You should change this line, instead of creating a new test
| from api.routes.chatbot import router | ||
|
|
||
|
|
||
| def test_start_chat(client, mock_init_session): |
There was a problem hiding this comment.
Use parametrize if necessary
| response.headers["Location"] = ( | ||
| f"/sessions/{session_id}/message" | ||
| ) | ||
| response.headers["Location"] = request.url_for( |
There was a problem hiding this comment.
In my mind, I thought Location would be used by UI to navigate the page.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Location
Content-Location may be more appropriate
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Location
|
Location on a 201 should point to the created resource itself ( |
Fixes #247.
Description
start_chatwas settingLocationvia a hardcoded path (/sessions/{id}/message), which ignores the API router prefix when mounted (default:/api/chatbot).This PR switches
Locationgeneration to route resolution so the header always matches mounted routes.Changes
chatbot-core/api/routes/chatbot.pyRequestparameter tostart_chatLocationwith:request.url_for("chatbot_reply", session_id=session_id).pathchatbot-core/tests/unit/routes/test_chatbot.pytest_start_chat_location_includes_router_prefixWhy this is aligned / scoped
LocationTesting done
pytest tests/unit/routes/test_chatbot.py -q->7 passedpylint api/routes/chatbot.py tests/unit/routes/test_chatbot.py->10.00/10Submitter checklist