Skip to content

fix: pass configured orgs to CreateUserParams in CreateAccount#134

Open
c1-dev-bot[bot] wants to merge 1 commit intomainfrom
fix/create-user-org-fallback
Open

fix: pass configured orgs to CreateUserParams in CreateAccount#134
c1-dev-bot[bot] wants to merge 1 commit intomainfrom
fix/create-user-org-fallback

Conversation

@c1-dev-bot
Copy link
Copy Markdown
Contributor

@c1-dev-bot c1-dev-bot bot commented Mar 26, 2026

Summary

  • CreateAccount called getCreateUserParams(accountInfo) which expected org in the account info profile map, but the platform doesn't pass it there
  • The connector already has the configured orgs available via invitationResourceType.orgs, but CreateAccount wasn't using them
  • Now getCreateUserParams accepts the connector's configured orgs and falls back to configuredOrgs[0] when the profile doesn't include an org

Root Cause

In pkg/connector/invitation.go, getCreateUserParams() only looked for org in accountInfo.Profile.AsMap(). The platform does not populate the org in the account info profile during provisioning — the org is a connector-level configuration. Other methods like Delete() correctly used i.orgs from the struct, but CreateAccount() did not.

Test Plan

  • Verify go build ./... passes
  • Verify go test ./... passes
  • Manual test: configure a GitHub Enterprise connector with an org, enroll a user without a GitHub account, confirm CreateAccount succeeds and sends an org invitation

Fixes: CXH-1257


Automated PR Notice

This PR was automatically created by c1-dev-bot as a potential implementation.

This code requires:

  • Human review of the implementation approach
  • Manual testing to verify correctness
  • Approval from the appropriate team before merging

CreateAccount was calling getCreateUserParams(accountInfo) which only
looked for "org" in the accountInfo profile map. The platform doesn't
pass the org through the profile, so this always failed with "org is
required" even when the connector had orgs configured.

Now getCreateUserParams accepts the connector's configured orgs and
falls back to configuredOrgs[0] when the profile doesn't include an org.

Fixes: CXH-1257
@c1-dev-bot c1-dev-bot bot requested a review from a team March 26, 2026 16:54
@linear
Copy link
Copy Markdown

linear bot commented Mar 26, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Claude finished @c1-dev-bot[bot]'s task in 43s —— View job


PR Review: fix: pass configured orgs to CreateUserParams in CreateAccount

  • Read the PR diff and changed file
  • Review for correctness, bugs, and best practices
  • Post review feedback

Review Summary

Verdict: Looks good

This is a clean, minimal fix for a real bug. The CreateAccount method wasn't using the connector's configured orgs (i.orgs), even though other methods like Delete (line 168) already did. The platform doesn't populate org in the account info profile during provisioning, so this was always failing with "org is required".

What the change does

  1. Passes i.orgs from the invitationResourceType struct into getCreateUserParams() (line 134)
  2. Updates getCreateUserParams to accept configuredOrgs []string and fall back to configuredOrgs[0] when the profile doesn't include an org (lines 213-216)
  3. Still returns an error if no org is available from either source (lines 217-218)

Analysis

Correctness: The fallback logic is sound. It tries the profile first, then the connector config, and errors only if neither provides an org. This mirrors how Delete uses i.orgs at line 168.

Edge cases handled:

  • Profile has org → uses it (no change in behavior)
  • Profile missing org, connector has orgs → uses configuredOrgs[0] (the fix)
  • Neither has org → returns error (preserved behavior)
  • configuredOrgs is nil/empty → safely handled by len(configuredOrgs) > 0 check

One minor note: The fix uses configuredOrgs[0], which is reasonable for the common single-org case. However, Delete iterates over all orgs (lines 183-188). If a multi-org connector calls CreateAccount, the invitation will always go to the first configured org. This seems intentional since account creation needs a single target org, but it's worth being aware of. If multi-org targeting becomes a requirement, this would need revisiting.

No issues found. The change is minimal, correctly scoped, and follows the existing patterns in the file.

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.

0 participants