Skip to content

Add assert to check for organization plan name - #31

Merged
Alex (alxhotel) merged 3 commits into
mainfrom
alex/fix-plan
Aug 25, 2026
Merged

Add assert to check for organization plan name#31
Alex (alxhotel) merged 3 commits into
mainfrom
alex/fix-plan

Conversation

@alxhotel

@alxhotel Alex (alxhotel) commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

Adds an assert to verify that the organization is inside a an enterprise plan

cc Douglas (@dacoburn)


Note

Medium Risk
Startup now hard-fails for non-Enterprise orgs; if plan is missing from the API response, org_plan.lower() could raise instead of the intended error message.

Overview
This PR gates socketsync startup on an Enterprise organization plan. During set_org_vars(), the client now loads the org plan from the Socket API (alongside id and slug) and immediately validates it.

get_org_id_slug() is replaced by get_org_id_slug_plan(), which reads plan from the org payload. A new assert_enterprise_plan() treats the plan as Enterprise when "enterprise" appears in the plan name (case-insensitive) and raises with a clear message if not, so non-Enterprise tokens fail fast before scans or sync run.

Reviewed by Cursor Bugbot for commit d08c3d7. Configure here.

@alxhotel
Alex (alxhotel) requested a review from a team as a code owner October 6, 2025 15:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Null plan crashes enterprise assert
    • Added a None check before calling .lower() on org_plan, treating None as non-enterprise to raise the intended Exception instead of AttributeError.

Create PR

Or push these changes by commenting:

@cursor push 2eed708b51
Preview (2eed708b51)
diff --git a/socketsync/core.py b/socketsync/core.py
--- a/socketsync/core.py
+++ b/socketsync/core.py
@@ -175,7 +175,7 @@
         :return: None
         :raises Exception: if the organization is not on the Enterprise plan
         """
-        is_enterprise = "enterprise" in org_plan.lower()
+        is_enterprise = org_plan is not None and "enterprise" in org_plan.lower()
         if not is_enterprise:
             raise Exception("This script requires an Enterprise plan organization")

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d08c3d7. Configure here.

Comment thread socketsync/core.py
The actions/checkout SHA 34e114876b0b11c390a56381ad16ebd13914f8d5 is
tagged v4.3.1, not v4 (v4 points at 11d5960a3267). zizmor's
ref-version-mismatch audit flags all three occurrences at medium
severity, which fails the workflow audit at --min-severity medium and
blocks every open pull request.

Only the trailing comments change; the pinned SHAs are untouched, so no
action version changes. Repinning to the v4 tag's current target was the
alternative, but that would silently move the action version and drift
again on the next v4 release.

Co-Authored-By: Claude <noreply@anthropic.com>
get_org_id_slug_plan leaves the plan as None when the token does not map
to exactly one organization, or when the org payload has no plan field.
assert_enterprise_plan then called .lower() on it and died with
AttributeError, so a common setup mistake surfaced as a confusing crash
instead of the intended message.

Check the plan is a non-empty string first and raise the fail-fast
Exception explaining the token must reach exactly one organization.

Co-Authored-By: Claude <noreply@anthropic.com>
@alxhotel
Alex (alxhotel) merged commit 3ce6635 into main Aug 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants