Fix SSO dataset error on site wide org - #1721
Open
vaimdevs wants to merge 10 commits into
Open
Conversation
vaimdevs
commented
Jul 10, 2026
Contributor
…false success switch_org() treated any status=='OK' response as a completed switch, but the server overloads that status for two different outcomes: a real switch (data has pk/org_name/organization_slug) and an SSO re-authentication challenge (data['idp'] populated) for members of SSO-protected orgs who aren't the owner/admin. The challenge case never actually updates the server-side active org, so treating it as success silently left callers on their previous org while locally claiming to have switched. Now raises with the idp names and a pointer to sso_login(org_name=...) as the alternative, instead of logging a false "Switched to organization" and setting self.session.org_name to a value the server never accepted.
_switch_org wrote _last_switched_org_token unconditionally after the POST, so a 403/500 or an SSO-challenge response (200 + data['idp']) got recorded as a completed switch. That poisoned memo made _maybe_switch_org short-circuit later, skipping switch_org() -- the only implementation that validates the response and raises on an SSO challenge. Now _switch_org returns without writing the memo on a non-2xx status or an idp challenge. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Aug 18, 2026
…ogic ArrowUploader._switch_org and GraphistryClient.switch_org each POSTed to the same org-switch endpoint with their own copy of the HTTP-status, body-status, and SSO-idp-challenge checks. Extract the shared logic into switch_org_request() in graphistry/utils/requests.py, raising OrgSwitchError / OrgSwitchIdpChallenge. Each caller keeps its own success/failure policy (ArrowUploader logs+swallows, GraphistryClient raises) since that divergence is intentional API contract, not duplication. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TNGYwRNwAFQdYDucbwgtUm
…quests.py Type-hygiene guard flagged missing __init__ return annotations and a bare dict for OrgSwitchIdpChallenge's idp param. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GgDZr3AgU9uKz5EWcVZZVY
vaimdev
force-pushed
the
fix/site-wide-org-dataset-error
branch
from
August 28, 2026 08:21
75c3b4f to
f043c72
Compare
Guard baseline already sat at max cast() count; cast() would've pushed it over. Use a localized type: ignore instead, per DEVELOP.md guidance. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GgDZr3AgU9uKz5EWcVZZVY
vaimdev
force-pushed
the
fix/site-wide-org-dataset-error
branch
from
August 28, 2026 08:50
f043c72 to
4a9d63e
Compare
Adds direct unit tests for graphistry/utils/requests.py's switch_org_request (success, HTTP error, non-OK body w/ detail, unparseable JSON, SSO idp challenge) and ArrowUploader._switch_org (no-op guards, dedup cache, OrgSwitchError/OrgSwitchIdpChallenge/generic-exception swallow paths), raising changed-line coverage on the switch-org refactor. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GgDZr3AgU9uKz5EWcVZZVY
mock.patch("graphistry.utils.requests.requests.post") failed under the
full suite (AttributeError: module 'graphistry' has no attribute 'utils')
because some other test's import juggling leaves the parent package's
'utils' attribute unset. mock.patch.object against the imported module
sidesteps the string-resolution path entirely.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GgDZr3AgU9uKz5EWcVZZVY
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.