Repository navigation
fix(watch): stop re-printing cloud audit rows when the dedup set hits its limit - #445
Open
leninworld wants to merge 1 commit into
Open
leninworld wants to merge 1 commit into
leninworld wants to merge 1 commit into
Conversation
…ate#223) pollCloud wiped the whole seen map once it passed seenLimit, right before checking the current batch, so the newest entries that had already been printed were printed again. Check the batch first, then keep only the batch's IDs when the set is over the limit; older IDs cannot return in the next newest-50 poll. Signed-off-by: Lenin Mookiah <2639584+leninworld@users.noreply.github.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 15 |
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
✅ No blocking issues noticed
No blocking findings were identified. The implementation has a recommended scenario covered, but regression coverage is missing for the at-or-below-limit case and for batches containing only previously seen IDs.
Test suggestions
- A batch containing both previously seen and new IDs is deduplicated, and an over-limit set is replaced with the current batch IDs.
- A set at or below the limit retains its existing IDs while adding new batch IDs.
- A batch containing only previously seen IDs produces no fresh entries.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. A set at or below the limit retains its existing IDs while adding new batch IDs.
2. A batch containing only previously seen IDs produces no fresh entries.
TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
solongate watchprints cloud audit entries it already showed once its dedup set passes 4096 IDs.pollCloudreplaced the set with an empty map before checking the current batch, so every entry in that batch (up to 50 newest rows) was printed again, each time the limit was crossed.The dedup now runs first and the set is bounded afterwards:
newCloudEntriesreturns the entries whose IDs aren't inseen, marks the batch as seen, and only when the set has grown pastseenLimitkeeps just the current batch's IDs. Each poll asks for the newest 50 entries, so an ID older than the current batch can't come back in the next poll, and nothing already shown is printed twice. This is the same approach as the Live panel fix for #205 (evict IDs that fell out of the window instead of wiping everything). The rows are built exactly as before.Tests:
TestNewCloudEntriesShrinksAfterDedupinwatch_test.gostarts with a set already over the limit that holds two of the batch's three IDs. It expects only the new entry back and a set of exactly the three batch IDs.mainhas no separate helper, so I checked the base behaviour by putting the old order (wipe, then check) into the helper: the test then fails withlen(fresh) = 3, want 1.Tested with Go 1.26.11 on macOS (arm64), in
packages/cli:go test ./observability/passes;go vet ./observability/is clean;gofmt -lis empty for both changed files.go test -count=1 ./...passes exceptcli/policy(TestProtectAdd,TestProtectList), whose TempDir cleanup fails withoperation not permittedon the protected file. It fails the same way onmainhere, so it's my environment.I didn't run
solongate watchagainst a live cloud account, so the 4096-entry case is covered by the unit test only.Fixes #223