fix(findings): feedback on an unknown finding answers 404
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Check (pull_request) Successful in 9m49s
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Check (pull_request) Successful in 9m49s
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
PATCH /api/v1/findings/{id}/feedback answered 200 when no finding has the
id, although nothing was written; the status endpoint already answers 404.
Found in the API-key E2E on stage.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
1 parent
07ba0d6665
commit
42257ddea5
2 files changed
+37
-2
No files matched your search
@@ -311,7 +311,9 @@ pub async fn bulk_update_finding_status(
|
||||
))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
/// PATCH /api/v1/findings/{id}/feedback — store the developer's feedback on a
|
||||
/// finding. 404 when there is no such finding.
|
||||
#[tracing::instrument(skip_all, fields(finding_id = %id))]
|
||||
pub async fn update_finding_feedback(
|
||||
Extension(agent): AgentExt,
|
||||
tenant: TenantCtx,
|
||||
@@ -321,13 +323,17 @@ pub async fn update_finding_feedback(
|
||||
let oid = mongodb::bson::oid::ObjectId::parse_str(&id).map_err(|_| StatusCode::BAD_REQUEST)?;
|
||||
let db = tenant_db(&agent, &tenant).await?;
|
||||
|
||||
db.findings()
|
||||
let result = db
|
||||
.findings()
|
||||
.update_one(
|
||||
doc! { "_id": oid },
|
||||
doc! { "$set": { "developer_feedback": &req.feedback, "updated_at": mongodb::bson::DateTime::now() } },
|
||||
)
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
if result.matched_count == 0 {
|
||||
return Err(StatusCode::NOT_FOUND);
|
||||
}
|
||||
|
||||
Ok(Json(serde_json::json!({ "status": "updated" })))
|
||||
}
|
||||
|
||||
@@ -104,6 +104,35 @@ async fn update_finding_status() {
|
||||
server.cleanup().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn feedback_on_an_unknown_finding_is_404() {
|
||||
let server = TestServer::start().await;
|
||||
|
||||
insert_finding(&server, "repo1", "Test Bug", "medium").await;
|
||||
let resp = server.get("/api/v1/findings").await;
|
||||
let body: serde_json::Value = resp.json().await.unwrap();
|
||||
let finding_id = body["data"][0]["_id"]["$oid"].as_str().unwrap();
|
||||
|
||||
let feedback = json!({ "feedback": "reviewed" });
|
||||
let resp = server
|
||||
.patch(
|
||||
&format!("/api/v1/findings/{finding_id}/feedback"),
|
||||
&feedback,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
|
||||
let resp = server
|
||||
.patch(
|
||||
"/api/v1/findings/000000000000000000000000/feedback",
|
||||
&feedback,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(resp.status(), 404);
|
||||
|
||||
server.cleanup().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn bulk_update_finding_status() {
|
||||
let server = TestServer::start().await;
|
||||
|
||||
Reference in new issue
Block a user