You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: align API clients with the current v3 API and add CI tests - #13
Updates the API clients that no longer match the live v3 responses and adds CI coverage:
Broker: latest() raised TypeError: BrokerItem.__init__() got an unexpected keyword argument 'delay'. Latest items carry a per-item delay (seconds since the latest catalog update), now modeled on BrokerItem. peers() and collectors() parsed outdated field shapes, and _paginate could loop forever on endpoints that ignore pagination parameters (it now pages until the reported total and also stops when a page adds no new items).
AsnLookup: v3 items are nested (as2org, hegemony, peeringdb, population); AsnInfo models them with org_name/org_id lifted from as2org, and Pagination matches the API object (total_pages, total_count, has_next, has_prev).
CommunityLookup: /communities is per-ASN with a nested community list; query() returns one CommunityEntry per community, and sources() reads the sources key instead of silently returning an empty list.
Roas: targets the v3 ROAS endpoint, paginates to the reported total, and uses the endpoint's 0-indexed page parameter.
Shared plumbing (bgpkit/_utils.py): from_item (dataclass parsing that ignores unknown fields), request_json (HTTP error surfacing with a configurable timeout), and BGPKITApiError. Requests now fail loudly instead of returning empty lists.
Broker base URL: BGPKIT_BROKER_URL is honored (the same variable the Rust broker client uses); an explicit api_url argument still wins.
Unit tests cover recorded response shapes for every client and a new Tests workflow runs them on push and pull request. The suite is green (17 tests), and all clients were also exercised against the live API.
latest() failed to parse because latest items carry a delay field; peers() and collectors() used outdated field shapes and could loop forever on endpoints that ignore pagination parameters; request errors now surface as BrokerApiError. Adds unit tests over recorded response shapes and BGPKIT_BROKER_URL support for the base URL.
…unit-test CI
AsnLookup parsed a flat item shape; v3 items are nested (as2org, hegemony, peeringdb, population). AsnInfo now models the nested fields and Pagination matches the API object. CommunityLookup described items that do not exist: /communities is per-ASN with a nested community list, so query() returns one entry per community and sources() reads the sources key. Roas now targets the v3 endpoint, paginates to the reported total, and uses the endpoint's 0-indexed page parameter. Shared parsing and HTTP error handling move to bgpkit/_utils (BGPKITApiError, from_item, request_json); the Broker client uses the same helpers. Adds unit tests for every client and a workflow that runs them on push and pull request.
digizeph
changed the title
fix: update Broker client to the current v3 API responses
fix: align API clients with the current v3 API and add CI tests
Oct 7, 2026
Default AsnLookup to page 0: the v3 ASN endpoint paginates from zero (verified live: page=0 returns the first page, page=1 the second), so the previous default skipped the first page of any broad query. request_json now wraps requests transport failures (timeouts, connection errors) in BGPKITApiError so all request failures surface through the exported exception. Adds assertions for both.
The full-feed thresholds are inclusive in BGPKIT's peer model (>= 700_000 IPv4 or >= 100_000 IPv6), so peers exactly at either threshold are currently misclassified as partial-feed. This can also contradict the result of peers(full_feed=True) for those boundary values.
On the full-feed boundary note for bgpkit_broker.py:46: keeping the comparison strict is intentional — the property mirrors the endpoint's own full-feed filter, which applies num_v4_pfxs > 700_000 || num_v6_pfxs > 100_000 for full_feed=true (the parameter documentation uses the same strict wording). An inclusive property would disagree with the server-side classification for peers exactly at a threshold. No peer in the current dataset sits exactly at either threshold (3,406 rows checked; nearest v6 counts 99,833 / 100,484), so this is a definitional edge with no behavioral impact today. If the API definition should become inclusive, the property can flip in the same change.
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
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.
Updates the API clients that no longer match the live v3 responses and adds CI coverage:
latest()raisedTypeError: BrokerItem.__init__() got an unexpected keyword argument 'delay'. Latest items carry a per-itemdelay(seconds since the latest catalog update), now modeled onBrokerItem.peers()andcollectors()parsed outdated field shapes, and_paginatecould loop forever on endpoints that ignore pagination parameters (it now pages until the reportedtotaland also stops when a page adds no new items).as2org,hegemony,peeringdb,population);AsnInfomodels them withorg_name/org_idlifted fromas2org, andPaginationmatches the API object (total_pages,total_count,has_next,has_prev)./communitiesis per-ASN with a nested community list;query()returns oneCommunityEntryper community, andsources()reads thesourceskey instead of silently returning an empty list.bgpkit/_utils.py):from_item(dataclass parsing that ignores unknown fields),request_json(HTTP error surfacing with a configurable timeout), andBGPKITApiError. Requests now fail loudly instead of returning empty lists.BGPKIT_BROKER_URLis honored (the same variable the Rust broker client uses); an explicitapi_urlargument still wins.Unit tests cover recorded response shapes for every client and a new
Testsworkflow runs them on push and pull request. The suite is green (17 tests), and all clients were also exercised against the live API.