Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/codex-security-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
- name: Checkout trusted workflow support
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

Expand Down Expand Up @@ -85,6 +86,7 @@ jobs:
- name: Checkout trusted workflow support
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

Expand Down Expand Up @@ -118,6 +120,7 @@ jobs:
if: matrix.pr_number != 0
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

Expand Down Expand Up @@ -156,6 +159,7 @@ jobs:
- name: Checkout trusted workflow support
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

Expand Down Expand Up @@ -197,6 +201,7 @@ jobs:
- name: Checkout trusted workflow support
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

Expand Down Expand Up @@ -233,6 +238,7 @@ jobs:
- name: Checkout exact pull request head
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
allow-unsafe-pr-checkout: true
ref: refs/pull/${{ needs.prepare-review.outputs.pr_number }}/head
path: ${{ env.REVIEW_REPOSITORY }}
fetch-depth: 0
Expand Down Expand Up @@ -467,6 +473,7 @@ jobs:
- name: Checkout trusted workflow support
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

Expand Down
38 changes: 38 additions & 0 deletions crates/buzz-db/src/store/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,14 @@ pub(crate) async fn get_channel_window_on(
cursor: Option<(DateTime<Utc>, Vec<u8>)>,
kind_filter: Option<&[u32]>,
) -> Result<ChannelWindow> {
if limit == 0 {
return Ok(ChannelWindow {
rows: Vec::new(),
has_more: false,
next_cursor: None,
});
}

let mut param_idx = 3u32; // $1 is community_id, $2 is channel_id
let mut sql = String::from(
r#"
Expand Down Expand Up @@ -1962,6 +1970,36 @@ mod tests {
assert_eq!(unique, expected_sorted, "paged set != inserted tied set");
}

/// A zero limit is a legitimate empty-page request. It must not perform
/// the internal limit+1 probe and then report has_more with no cursor.
#[tokio::test]
#[ignore = "requires Postgres"]
async fn channel_window_zero_limit_returns_empty_page() {
let pool = setup_pool().await;
let author = Keys::generate();
let (channel, community) = create_test_channel(
&pool,
&format!("window-zero-{}", Uuid::new_v4()),
ChannelType::Stream,
ChannelVisibility::Open,
None,
author.public_key().to_bytes().as_slice(),
None,
)
.await
.expect("create channel");

let event = make_stream_event(&author, "row");
insert_root(&pool, community, channel.id, &event).await;

let window = get_channel_window(&pool, community, channel.id, 0, None, None)
.await
.expect("fetch zero-limit window");
assert!(window.rows.is_empty());
assert!(!window.has_more);
assert!(window.next_cursor.is_none());
}

/// The exact-multiple final page: when the channel's row count is an
/// exact multiple of the page limit, the last full page must report
/// `has_more = false` (from the limit+1 probe) even though it contains
Expand Down