Skip to content

BgpSessionDataAggregator: fix logic bug - #1099

Merged
barryo merged 1 commit into
mainfrom
bgp-session-data-aggregator
Sep 21, 2026
Merged

barryo merged 1 commit into
mainfrom
bgp-session-data-aggregator

Conversation

@afk11

@afk11 afk11 commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

The BgpSessionDataAggregator::getPeers function takes a parameter (?int $asn = null).

The parameter is not currently used, so nothing should be affected by it so far.

The code passes $asn != null into when, and then uses the result of that expression as an ASN in the query

            ->when( $asn != null, function( Builder $q, $asn ) {
                return $q->where( 'cs.autsys', (int) $asn );
            } )

In the closure, $asn is true or false, which when cast to an int is 0 or 1.

Instead we can rely on when to perform the truthiness check (ensure $asn isn't 0 or null), then typehint $asn as an int, and then the query will work as intended.

…rameter is unused. since the first parameter to when is a boolean. using this the value provided to the closure as an ASN in the query is now incorrect. rely on when's truthiness check instead
@barryo
barryo merged commit 950e55f into main Sep 21, 2026
3 checks passed
@barryo
barryo deleted the bgp-session-data-aggregator branch September 21, 2026 14:04
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