From eb9f4e9ec52b0a3cd94a708fe10e5267e2b4b68b Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Sun, 29 Nov 2026 17:41:46 +0100 Subject: [PATCH] fix(forge): mark a GitHub notification read with PATCH GitHub's read route is `PATCH /notifications/threads/{thread_id}`; the adapter sent PUT, which does not exist, so every call answered 404 and the thread stayed unread. The account feed then returned the same row again whenever its `updated_at` moved, and that timestamp is part of the dedup id: the merge bumped the row once, the reply to that turn bumped it again, so one assignment ran three turns and the merged PR got two replies. The test mounted PUT as well, so it asserted the bug. Both now use PATCH, whose 205 response `ensure_success` already accepted. fmt, clippy with -D warnings over all features and targets, the workspace tests, and the doc build pass. --- crates/rhema-claw/src/forge.rs | 2 +- integrations/rhema-forge-integration/src/github.rs | 14 +++++++++----- .../rhema-forge-integration/tests/github.rs | 12 ++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/rhema-claw/src/forge.rs b/crates/rhema-claw/src/forge.rs index 632e931..c54b666 100644 --- a/crates/rhema-claw/src/forge.rs +++ b/crates/rhema-claw/src/forge.rs @@ -764,7 +764,7 @@ mod tests { let requests = server.received_requests().await.expect("recording is on"); let reads: Vec<_> = requests .iter() - .filter(|request| request.method.as_str() == "PUT") + .filter(|request| request.method.as_str() == "PATCH") .collect(); assert_eq!(reads.len(), 1, "one mark-read per triaged row"); assert_eq!(reads[0].url.path(), "/notifications/threads/42188"); diff --git a/integrations/rhema-forge-integration/src/github.rs b/integrations/rhema-forge-integration/src/github.rs index f0bf980..f3089d3 100644 --- a/integrations/rhema-forge-integration/src/github.rs +++ b/integrations/rhema-forge-integration/src/github.rs @@ -120,10 +120,10 @@ impl GitHubForge { } } - /// A PUT builder for `path` with auth applied. - fn put(&self, path: &str) -> reqwest::RequestBuilder { + /// A PATCH builder for `path` with auth applied. + fn patch(&self, path: &str) -> reqwest::RequestBuilder { let base = &self.base_url; - let request = self.http.put(format!("{base}{path}")); + let request = self.http.patch(format!("{base}{path}")); if self.token.is_empty() { request } else { @@ -520,7 +520,7 @@ fn notification_event(row: &WireNotification) -> Result, Fo title: subject.title.clone(), url: None, timestamp: updated, - // `PUT /notifications/threads/{id}` is keyed on this same id: + // `PATCH /notifications/threads/{id}` is keyed on this same id: // the notification, not the thread's number. read_key: Some(id.to_string()), raw: Value::Object(row.raw.clone()), @@ -761,7 +761,11 @@ impl Forge for GitHubForge { ))); }; let path = format!("/notifications/threads/{read_key}"); - let response = self.put(&path).send().await.map_err(ForgeError::network)?; + let response = self + .patch(&path) + .send() + .await + .map_err(ForgeError::network)?; // 205 Reset Content: marked, nothing to decode. ensure_success(response).await?; Ok(()) diff --git a/integrations/rhema-forge-integration/tests/github.rs b/integrations/rhema-forge-integration/tests/github.rs index b460f22..0d211ff 100644 --- a/integrations/rhema-forge-integration/tests/github.rs +++ b/integrations/rhema-forge-integration/tests/github.rs @@ -554,7 +554,7 @@ fn notification_row(id: i64, reason: &str, number: u64) -> Value { /// repeat. It keys on the notification's own id, not the thread number — /// the dedup id keeps that integer only as text. #[tokio::test] -async fn marking_a_notification_read_puts_its_thread() { +async fn marking_a_notification_read_patches_its_thread() { let server = MockServer::start().await; Mock::given(method("GET")) .and(path("/notifications")) @@ -567,7 +567,7 @@ async fn marking_a_notification_read_puts_its_thread() { ) .mount(&server) .await; - Mock::given(method("PUT")) + Mock::given(method("PATCH")) .and(path("/notifications/threads/42188")) .and(header("authorization", "Bearer tok")) .respond_with(ResponseTemplate::new(205)) @@ -580,12 +580,12 @@ async fn marking_a_notification_read_puts_its_thread() { forge.mark_read(notification).await.expect("marks read"); let requests = server.received_requests().await.expect("recording is on"); - let puts: Vec<_> = requests + let patches: Vec<_> = requests .iter() - .filter(|request| request.method.as_str() == "PUT") + .filter(|request| request.method.as_str() == "PATCH") .collect(); - assert_eq!(puts.len(), 1, "one read call, on the row's id"); - assert_eq!(puts[0].url.path(), "/notifications/threads/42188"); + assert_eq!(patches.len(), 1, "one read call, on the row's id"); + assert_eq!(patches[0].url.path(), "/notifications/threads/42188"); } /// A row that reaches the caller with no read key is a shape break, not a