Skip to content

Fix | Make aws sso logout idempotent, check project_long before configure sso logs in - #352

Merged
diego-ojeda-binbash merged 2 commits into
masterfrom
fix/issue-350-sso-logout-project-long
Nov 14, 2026
Merged

diego-ojeda-binbash merged 2 commits into
masterfrom
fix/issue-350-sso-logout-project-long

Conversation

@diego-ojeda-binbash

Copy link
Copy Markdown
Contributor

What?

Fixes both crashes from #350, with option (a) in each case, plus one more found along the way:

Case Before After
sso logout with no cached token FileNotFoundError traceback Reports "No active AWS SSO session found", cleans up, exits 0
sso logout with an expired token UnauthorizedException traceback Warns that the session could not be ended, cleans up anyway, exits 0
sso logout with no credentials file (new) FileNotFoundError traceback Exits 0
configure sso without project_long TypeError after the login, profiles half configured Clear error next to the other SSO settings, before sending the user to log in

logout is now idempotent: it ends the session when it can, and always removes the local SSO tokens and credentials. It also drops the removal of credentials sections, which was dead code: the whole file was deleted right after.

Two commits:

  1. The fix, plus 4 tests: logout without a session, logout twice in a row, logout with an expired token, and configure sso without project_long. All 4 fail on the current code.
  2. Hardening of the aws CLI tests: the cli fixture now always installs the AWS (Stubber), browser and sleep fakes. Before, a test that did not ask for stubs used real boto3 clients. While checking that the new tests fail on the old code, the project_long case ran into the real SSO login: it made unauthenticated calls to AWS SSO-OIDC (with a made-up start URL, no account involved) and polled forever. Now any unexpected call fails at once.

Why?

#350: both commands showed a Python traceback instead of a clear message. The configure sso crash also left the AWS config half written.

Results

322 tests pass. Against the current code, the 4 new tests fail in ~7 s.

Closes #350
Relates to #346

🤖 Generated with Claude Code

diego-ojeda-binbash and others added 2 commits November 14, 2026 15:57
…gure sso logs in

* `sso logout` no longer crashes when there is no cached token, when the
  token already expired (UnauthorizedException), or when there is no
  credentials file. It ends the session when it can, warns when it cannot,
  and always removes the local SSO tokens and credentials. The removal of
  credentials sections right before deleting the whole file is dropped.
* `configure sso` checks `project_long` next to the other SSO settings.
  It used to fail with a TypeError after the login, leaving the profiles
  half configured.

Closes #350

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… fakes

A test that did not ask for the `stubs` fixture used real boto3 clients: a
regression that reached the SSO login made real, unauthenticated calls to
AWS SSO-OIDC and polled forever. The `cli` fixture now always installs the
fakes, so an unexpected call fails at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@diego-ojeda-binbash diego-ojeda-binbash added bug Something isn't working test labels Nov 14, 2026
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fd0cd4a9-1e29-4daa-b6b5-ec5498ff733b
Commits

Reviewing files that changed from the base of the PR and between 2ee5ca7 and ed6b1d6.

Files selected for processing: 2

  • leverage/modules/aws.py
  • tests/test_modules/test_aws.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@diego-ojeda-binbash diego-ojeda-binbash self-assigned this Nov 14, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 43629475593

Coverage increased (+0.09%) to 73.069%

Details

  • Coverage increased (+0.09%) from the base build.
  • Patch coverage: 12 of 12 lines across 1 file are fully covered (100%).
  • 2 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
modules/aws.py 2 97.32%

Coverage Stats

Coverage Status
Relevant Lines: 4074
Covered Lines: 3110
Line Coverage: 76.34%
Relevant Branches: 1080
Covered Branches: 656
Branch Coverage: 60.74%
Branches in Coverage %: Yes
Coverage Strength: 0.76 hits per line

💛 - Coveralls

@diego-ojeda-binbash
diego-ojeda-binbash merged commit e4e6c38 into master Nov 14, 2026
28 of 32 checks passed
@diego-ojeda-binbash
diego-ojeda-binbash deleted the fix/issue-350-sso-logout-project-long branch November 14, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG | aws sso logout and configure sso crash with a traceback on missing token or project_long

3 participants