Repository navigation
Log why a new repository couldn't be created - #436
Open
David Larsen (dc-larsen) wants to merge 1 commit into
Open
David Larsen (dc-larsen) wants to merge 1 commit into
David Larsen (dc-larsen) wants to merge 1 commit into
Conversation
get_repo_info mutes the socketdev logger around the repository lookup and only restored the level after a successful lookup. This module logs through the same logger, so when the lookup raised for a repository that isn't in Socket yet, the "attempting to create it" warning and the creation error were dropped, and the CLI exited 2 right after file discovery with nothing logged. A successful create also left logging muted for the rest of the run. Restore the level in a finally block, and include the repository, the HTTP status and, on a 403, a repo:create hint in the creation error. The SDK keeps only the API's "Insufficient permissions" message and drops the required scope. Bump to 2.11.9.
David Larsen (dc-larsen)
deployed
to
socket-firewall
November 1, 2026 22:39 — with
GitHub Actions
Active
This branch was successfully deployed
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.
When a repository isn't in Socket yet and the API token can't create it (for example, the token has
repo:listbut notrepo:create), the CLI exits2right after file discovery with nothing logged, so CI users have no way to tell what went wrong. Related to CE-127.Root Cause
get_repo_infosets thesocketdevlogger toCRITICALaround the repository lookup and only restored the level after a successful lookup.socketsecurity.corelogs through that same logger, so when the lookup raised (a 404 for a repository Socket hasn't seen), the "attempting to create it" warning and the creation error were both dropped beforesys.exit(2). When the create succeeded, logging stayed muted for the rest of the run.Fix
finallyaround the lookup.repo:createhint in the creation error. The SDK keeps only the API'sInsufficient permissionsmessage and drops the required scope from the response.2).tests/core/test_sdk_methods.py. Both fail onmain: no records reach the log, and the logger is still atCRITICALafter a successful create.Testing
uv run pytest tests/unit tests/core: 729 passed.ruff checkclean,uv lock --lockedin sync,hatch build+twine checkpass.repo:listbut notrepo:create, on a repository Socket hadn't seen:2, the log ends atFile count (1) is within file descriptor limit.2withrepo:create: the CLI creates the repository and completes the scan (exit0), with logging continuing after the create. A rerun on the now-existing repository takes the normal path with no create attempt.Public Changelog
The Socket Python CLI now explains why it couldn't create a repository that isn't in Socket yet, including the HTTP status and a hint about the
repo:createscope, instead of exiting with no output.Note
Low Risk
Localized logging and error-message changes in
get_repo_info; no change to exit codes or API behavior beyond surfacing failures that were already occurring.Overview
Fixes a silent exit 2 when the CLI tries to auto-create a repository that is not in Socket yet but the API token cannot create it (for example missing
repo:create).In
Core.get_repo_info, thesocketdevlogger is temporarily set toCRITICALduring the repo lookup. The level is now restored in afinallyblock so a failed lookup no longer leaves logging muted for the rest of the run. That restores the “attempting to create it” warning and creation error lines that were previously dropped becausesocketsecurity.corealso logs throughsocketdev.When repository creation fails, errors now include the repo slug, HTTP status when available, and on 403 a hint that the token may need
repo:create. Exit code 2 on that path is unchanged. Release 2.11.9 with matching tests.Reviewed by Cursor Bugbot for commit aa2299b. Configure here.