Repository navigation
Conversation
Add an "API token scopes" section to the README that maps every SDK method to the endpoint it calls and the scopes that endpoint checks, matching the per-endpoint scopes in the public API reference. It also explains how a 401 or 403 surfaces: a missing scope raises APIAccessDenied with status_code 403 and the server's "Insufficient permissions" message, and 403s with more specific messages raise APIInsufficientPermissions, APIOrganizationNotAllowed or APIInsufficientQuota, all subclasses of APIFailure. Methods whose endpoint the reference does not list are marked as such rather than given a guessed scope.
The method requested orgs/{org}/settings/integrations/{id}, which has no
GET route, so it always failed. The events listing lives under /events
and checks integration:list.
GET .../integrations/{integration_id}/events answers with a bare JSON
array of events. The method was annotated -> dict and fell back to {},
and its test mocked a {"results": [...]} wrapper the API never sends.
The annotation and fallback are now a list, and the fixture has the
shape of a real event.
Checked against the API's route handlers: - Three calls request a path with no route and always fail with a 404: apitokens.update(token_id=...), dependencies.get() with all four arguments, and repositories.list(). They were marked "not in the API reference", which read as working but undocumented. - sbom.view() checks report:read. - settings.integration_events() is listed with the /events path and integration:list. - POST dependencies/search checks no scope at the route but filters results by dependencies:list repository access. - The API sends neither "Insufficient permissions for API method" nor "Organization not allowed", so APIInsufficientPermissions and APIOrganizationNotAllowed are not raised today. A missing scope is APIAccessDenied. Also marks the endpoints the API reference lists as deprecated, and explains scope groups and tokens restricted to specific repositories.
…h' into lelia/prune-unrouted-sdk-calls
… lelia/prune-unrouted-sdk-calls
Three calls could not succeed, because the API has no route for the
path they requested:
- apitokens.update(token_id=...) sent PUT orgs/{org}/api-tokens/{id}.
The method now always posts to api-tokens/update, which reads the
token from the request body.
- dependencies.get() with org_slug, ecosystem, package and version sent
GET orgs/{org}/dependencies/... The method now only searches, with the
get(limit, offset) signature the README documents. Positional
arguments used to bind to the removed parameters and were ignored.
- repositories.list() sent GET repos. The module is removed;
repos.get(org_slug) lists repositories.
The README scope table drops the three rows and their note, and its
apitokens.update example names the token with uuid instead of token_id.
|
bugbot run |
PR SummaryMedium Risk Overview
The Reviewed by Cursor Bugbot for commit f978eb4. Configure here. |
…anded The branch was stacked on both. Its diff against main is now only the removal of the three unrouted calls, as 3.6.4.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f978eb4. Configure here.
Three SDK calls requested a path the API has no route for, so each one failed with a 404 on every request, whatever the token. The README scope table from #130 documents them as "no such route; the call fails". This PR removes them. It follows #131, which fixed the fourth call of this kind,
settings.integration_events().apitokens.update(token_id=...)PUT orgs/{org_slug}/api-tokens/{token_id}POST orgs/{org_slug}/api-tokens/update, with the token named in the bodydependencies.get(org_slug, ecosystem, package, version)GET orgs/{org_slug}/dependencies/{ecosystem}/{package}/{version}POST dependencies/searchrepositories.list()GET reposrepos.get(org_slug)Changes
apitokens.update()no longer takestoken_id. It always posts toapi-tokens/update. That endpoint reads the token to update from the request body, as exactly one ofuuid,id,tokenorhash, so callers pass one of those as a keyword argument.dependencies.get()no longer takesorg_slug,ecosystem,packageandversion. Its signature isget(limit=50, offset=0), which is what the README already documents, and it always searches.repositoriesis removed: the module, and therepositoriesattribute on the client.list()was its only method.apitokens.updateexample names the token withuuidinstead oftoken_id, and usesscopes, the field the API accepts. The "Deprecated: repositories.get()" section is gone; that method never existed.Compatibility
These are signature changes, so worth a careful look:
dependencies.get()bound positional arguments to the removed parameters and ignored them, soget(10, 0)ran with the default limit and offset. Positional arguments now setlimitandoffset. A call likedependencies.get("my-org")would now send that string as the limit.dependencies.get()raisesTypeError. Passingtoken_idtoapitokens.update()sends it in the body, and the API answers 400 because no valid identifier is present.Testing
Unit tests pass: 195 passed, 1 skipped. The updated tests assert the method, path and request body for
apitokens.update()anddependencies.get(), and a new test checks that the removed package arguments raiseTypeErrorwithout sending a request.The mocked tests under
tests/integrationare not run in CI. I updated the ones that used the removed forms. The same 11 of them fail before and after this change, for unrelated reasons.Public Changelog
Removed three SDK calls that could never succeed because the API has no route for them:
apitokens.update(token_id=...), the four-argument form ofdependencies.get(), andrepositories.list().Fixes: CE-513
Refs: CE-462