Skip to content

Commit 2d0dc3b

Browse files
alonelishclaude
andcommitted
Forward user_id as query param on holmes_feedback
Holmes' POST /api/feedback reads user_id from request.query_params, not the JSON body (mirrors /api/chat's resolution path used by the relay). Posting it in the body returns 400 "missing user_id". Pull user_id out of the action params and forward it via the URL query string. - Declare user_id: Optional[str] on HolmesFeedbackParams so it's discoverable; pop it before constructing the request body. - Update tests to assert user_id is on params= and not in the body. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8ce1a18 commit 2d0dc3b

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/robusta/core/model/base_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ class HolmesFeedbackParams(HolmesParams):
253253
sentiment: Literal["thumbs_up", "thumbs_down"]
254254
category: Optional[str] = None
255255
comment: Optional[str] = None
256+
user_id: Optional[str] = None
256257

257258
class Config:
258259
extra = "allow"

src/robusta/core/playbooks/internal/ai_integration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,16 @@ def holmes_feedback(event: ExecutionBaseEvent, params: HolmesFeedbackParams):
445445
)
446446

447447
try:
448+
# Holmes reads user_id from the query string (not the body) on
449+
# /api/feedback — see server.py's `query_params.get("user_id")`.
450+
# Pull it out of the params and forward as a URL query param.
448451
params_dict = params.dict(exclude={"holmes_url", "model"})
452+
user_id = params_dict.pop("user_id", None)
449453
holmes_req = HolmesFeedbackRequest(**params_dict)
450454
result = requests.post(
451455
f"{holmes_url}/api/feedback",
452456
data=holmes_req.json(),
457+
params={"user_id": user_id} if user_id else None,
453458
timeout=30,
454459
)
455460
result.raise_for_status()

tests/test_ai_integration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def test_holmes_feedback_posts_correct_body(mock_post, mock_event):
221221
sentiment="thumbs_down",
222222
category="wrong_answer",
223223
comment="missed the actual cause",
224+
user_id="u-42",
224225
holmes_url="http://test-holmes:8080",
225226
)
226227

@@ -238,6 +239,9 @@ def test_holmes_feedback_posts_correct_body(mock_post, mock_event):
238239
# holmes_url and model are runner-only and must NOT be forwarded
239240
assert "holmes_url" not in body
240241
assert "model" not in body
242+
# user_id goes on the query string, not the body — Holmes reads it from query_params
243+
assert "user_id" not in body
244+
assert call_args[1]["params"] == {"user_id": "u-42"}
241245

242246
mock_event.add_finding.assert_called_once()
243247

@@ -260,6 +264,8 @@ def test_holmes_feedback_minimal_body(mock_post, mock_event):
260264
assert body["sentiment"] == "thumbs_up"
261265
assert body["category"] is None
262266
assert body["comment"] is None
267+
# No user_id supplied → no params kwarg sent (don't forge an empty user_id)
268+
assert mock_post.call_args[1]["params"] is None
263269

264270

265271
def test_holmes_feedback_missing_request_id_raises():

0 commit comments

Comments
 (0)