fix: separate merge request authority from thread projection

This commit is contained in:
2026-08-17 07:46:48 +09:00
parent 7e9cae5f39
commit 6c4119e2c6
3 changed files with 28 additions and 4 deletions
+5 -3
View File
@@ -807,14 +807,16 @@ fn truncate_body(value: &mut String) {
if value.len() <= MAX_BODY_BYTES {
return;
}
const MARKER: &str = "\n[truncated]";
let limit = MAX_BODY_BYTES.saturating_sub(MARKER.len());
let boundary = value
.char_indices()
.map(|(index, _)| index)
.take_while(|index| *index <= MAX_BODY_BYTES)
.take_while(|index| *index <= limit)
.last()
.unwrap_or(0);
value.truncate(boundary);
value.push_str("\n[truncated]");
value.push_str(MARKER);
}
fn bounded_body(name: &str, value: &str) -> Result<(), MergeRequestError> {
@@ -889,7 +891,7 @@ fn load_mr(c: &Connection, w: &str, m: &str) -> Result<Option<MergeRequest>, Mer
ticket_ids: tickets,
created_at: time(&created)?,
updated_at: time(&updated)?,
thread: load_thread(c, w, m, None, 100)?,
thread: load_thread(c, w, m, None, i64::MAX as usize)?,
}))
}
fn load_thread(
+20
View File
@@ -213,3 +213,23 @@ fn v11_migration_preserves_review_events_and_requires_selector_repair() {
.unwrap();
assert!(!old);
}
#[test]
fn authority_reads_full_thread_while_public_pages_remain_bounded() {
let (_d, store) = fixture();
open(&store);
for index in 0..55 {
approve(&store, "same-subject", &format!("token-{index}"));
}
let mr = store.get("W", "T").unwrap();
assert!(mr.thread.len() > 100);
assert_eq!(
mr.effective_review("same-subject").unwrap().decision,
ReviewDecision::Approve
);
assert_eq!(store.thread_page("W", "T", None, 20).unwrap().len(), 20);
assert_eq!(
store.thread_page("W", "T", Some(100), 20).unwrap().len(),
11
);
}