Skip to content

fix(no-ticket): degrade gracefully when auth can't open a browser (#194) - #350

Open
BartoszBlizniak wants to merge 4 commits into
cloudsmith-io:masterfrom
BartoszBlizniak:issue-194-auth-no-browser
Open

fix(no-ticket): degrade gracefully when auth can't open a browser (#194)#350
BartoszBlizniak wants to merge 4 commits into
cloudsmith-io:masterfrom
BartoszBlizniak:issue-194-auth-no-browser

Conversation

@BartoszBlizniak

Copy link
Copy Markdown
Member

Description

Addresses the Cygwin and same-host headless-shell portion of issue #194. cloudsmith auth now handles both exceptions and falsey results from webbrowser.open() by showing a manual-open fallback and continuing to wait for the existing localhost SAML callback. A new --no-browser option on both cloudsmith auth and cloudsmith authenticate skips automatic browser launch and presents the IdP URL for the user to open manually. The URL banner is neutral in every mode, and existing informational output routing is preserved. This does not add support for remote or fully browserless authentication: the callback still binds to 127.0.0.1:12400, and a device-authorization-style flow requires backend support outside this change.

The README's SAML section is updated for the new banner text, documents --no-browser and the automatic fallback, and now states the same-machine constraint on the callback. CHANGELOG has Added/Fixed entries under Unreleased.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

Regression coverage exercises the registered top-level Click command tree for auth and authenticate, including webbrowser.Error, an unexpected browser-launch exception, a false return value, --no-browser, successful automatic launch, and continuation into AuthenticationWebServer.handle_request(). Focused auth tests pass (14 passed), the full suite passes (632 passed, 40 skipped), and pre-commit run --all-files passes. Both command names expose --no-browser in generated local help. A live SAML round trip was not performed because no SSO-enabled test organization was available; browser-launch behavior and callback continuation are covered with local mocks, and no external service was modified.

BartoszBlizniakand others added 3 commits August 12, 2026 23:40
…oudsmith-io#194)
cloudsmith auth's SAML flow called webbrowser.open() with no error
handling, so on Cygwin and similar environments without a runnable
browser it crashed with an uncaught webbrowser.Error traceback instead
of falling back to the already-printed IdP URL. Wrap the call and
print a manual-open hint instead of crashing, and add a --no-browser
flag to skip the auto-open step entirely for callers who know upfront
they're in that kind of environment.
…th-io#194)
Add CHANGELOG entries and update the README's SAML section, which still
showed the "Opening your organization's SAML IDP URL in your browser"
banner this change replaced. Also note the callback binds to
127.0.0.1:12400, so the browser must be on the same machine.
Drop the dead pylint pragma (the repo runs ruff, which already ignores
BLE001 repo-wide), trim the --no-browser help to one sentence, and remove
a no-op mock assignment in the webbrowser.Error test.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds graceful browser-launch fallback to SAML authentication.

Changes:

  • Adds --no-browser to auth/authenticate.
  • Handles browser launch failures while preserving callback flow.
  • Adds regression tests and documentation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

FileDescription
README.mdDocuments manual browser authentication.
cloudsmith_cli/cli/commands/auth.pyImplements browser fallback and option.
cloudsmith_cli/cli/tests/commands/test_auth.pyTests launch and fallback behavior.
CHANGELOG.mdRecords the feature and fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment threadCHANGELOG.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@BartoszBlizniak
BartoszBlizniak marked this pull request as ready for review August 14, 2026 12:08
@BartoszBlizniak
BartoszBlizniak requested a review from a team as a code ownerAugust 14, 2026 12:08

@cloudsmith-iduffycloudsmith-iduffy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice addition and makes sense.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@BartoszBlizniak@cloudsmith-iduffy