Skip to content

test: check $gt/$gte/$lt/$lte filters at the bound - #1264

Merged
alexluong merged 2 commits into
hookdeck:mainfrom
Trenyx:test/filter-gte-equal-bound
Nov 25, 2026
Merged

alexluong merged 2 commits into
hookdeck:mainfrom
Trenyx:test/filter-gte-equal-bound

Conversation

@Trenyx

@Trenyx Trenyx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

If $gte on numbers ever became a strict >, a destination filtered on { "data": { "amount": { "$gte": 100 } } } would stop receiving events with amount: 100, those events would never be delivered, and no test would notice.

Tests only: one test (+25 lines) in internal/simplejsonmatch/match_test.go. No change to library code.

The filter docs (docs/content/features/filter.mdoc) describe $gte as "Greater than or equal" and $lte as "Less than or equal". The existing cases check $gte only well above the bound (10 >= 5) and $lte only inside arrays, so the equal-to-the-bound case is not pinned. TestMatchInclusiveBounds checks both operators at the bound and one step outside it, in the same table style as TestMatch.

How it was checked

On main 8e537a8:

  • go test -short -count=1 ./internal/simplejsonmatch/ ./internal/models/: both ok. gofmt and go vet are clean.
  • With return vNum >= cNum, nil in opGte changed to return vNum > cNum, nil, this new test is the only one that fails (Match({"amount":100}, {"amount":{"$gte":100}}) = false, want true); go test -short ./... shows no other failure.

This test was written with Claude Code during a planted-bug run by SK @ Trenyx.

The existing cases check $gte only well above the bound and $lte only
inside arrays, so a strict comparison at the bound would go unnoticed.
Destinations filtered with $gte or $lte would silently miss events whose
field equals the bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexluong

Copy link
Copy Markdown
Collaborator

Thanks, good catch! Could you add the strict side too, so a $gt/$lt that turned inclusive gets caught: {"amount":100} with {"$gt":100} → false and with {"$lt":100} → false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Trenyx Trenyx changed the title test: check that $gte and $lte filters match a value equal to the bound test: check $gt/$gte/$lt/$lte filters at the bound Nov 25, 2026
@Trenyx

Trenyx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Done, added both: $gt and $lt now each have a case at the bound expecting false. I checked that the test fails if either one turns inclusive.

Same run found one more gap you might want: in the event list API, if the time filter's GT and LT got swapped when building the log query, no test would notice, and a time-range query would come back empty. I'm also running a wider pass over outpost now and will let you know what else turns up. Happy to send small separate PRs for anything useful.

@alexluong alexluong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the prompt response and for your contribution! Yes, go ahead with the event list one, I'll review it.

@alexluong
alexluong merged commit af13e96 into hookdeck:main Nov 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants