fix(forge): mark a GitHub notification read with PATCH
android / debug (push) Successful in 2m15s
android / release (push) Successful in 2m32s
ci / test (push) Successful in 2m3s
ci / checks (push) Successful in 3m47s
ci / docker (push) Successful in 1m47s
ci / chart (push) Successful in 6s
ci / web (push) Successful in 12s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Successful in 1m52s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Successful in 9s
ci / publish-edge-chart (push) Successful in 4s

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.
This commit is contained in:
vhaudiquet committed 2026-11-29 17:41:46 +01:00
1 parent 5e7e2dcfe7
commit eb9f4e9ec5
3 files changed
+16 -12

No files matched your search

+1 -1
View File
@@ -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");
@@ -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<Option<Notification>, 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(())
@@ -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