Thanks to visit codestin.com
Credit goes to github.com

Skip to content

internal: fix MaxSizeSubjectsListForLog off-by-one when maxToDisplay is 0 - #7970

Open
mohammed90 wants to merge 2 commits into
masterfrom
fix-max-size-subjects-list-for-log-off-by-one
Open

internal: fix MaxSizeSubjectsListForLog off-by-one when maxToDisplay is 0#7970
mohammed90 wants to merge 2 commits into
masterfrom
fix-max-size-subjects-list-for-log-off-by-one

Conversation

@mohammed90

Copy link
Copy Markdown
Member

The loop appended before checking the length, so with maxToDisplay=0 one domain leaked into the output before the break check. Reorder so the length check comes first.

Assistance Disclosure

Test was generated by copilot/Claude 4.7; fixed by the same.

Related to #7227

…is 0

The loop appended before checking the length, so with maxToDisplay=0
one domain leaked into the output before the break check. Reorder so
the length check comes first.

Signed-off-by: Mohammed Al Sahaf <[email protected]>
@mohammed90 mohammed90 added the bug 🐞 Something isn't working label Aug 30, 2026
Comment thread internal/logs.go
Comment thread internal/logs.go
Comment on lines 5 to 8
// MaxSizeSubjectsListForLog returns the keys in the map as a slice of maximum length
// maxToDisplay. It is useful for logging domains being managed, for example, since a
// map is typically needed for quick lookup, but a slice is needed for logging, and this
// can be quite a doozy since there may be a huge amount (hundreds of thousands).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// MaxSizeSubjectsListForLog returns up to maxToDisplay keys from subjects.
// If any keys are omitted, it appends one additional entry summarising the
// omitted count. This bounds the number of subject names placed in the log
// while making truncation explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants