From 504a7f649f0a23d0e213b3f08aac24fb7831c06b Mon Sep 17 00:00:00 2001 From: "c1-dev-bot[bot]" <2740113+c1-dev-bot[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 16:54:42 +0000 Subject: [PATCH] fix: pass configured orgs to CreateUserParams in CreateAccount 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 --- pkg/connector/invitation.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/connector/invitation.go b/pkg/connector/invitation.go index c74f6d38..b18e8160 100644 --- a/pkg/connector/invitation.go +++ b/pkg/connector/invitation.go @@ -131,7 +131,7 @@ func (i *invitationResourceType) CreateAccount( annotations.Annotations, error, ) { - params, err := getCreateUserParams(accountInfo) + params, err := getCreateUserParams(accountInfo, i.orgs) if err != nil { return nil, nil, nil, fmt.Errorf("github-connectorv2: failed to get CreateUserParams: %w", err) } @@ -206,10 +206,15 @@ type createUserParams struct { email *string } -func getCreateUserParams(accountInfo *v2.AccountInfo) (*createUserParams, error) { +func getCreateUserParams(accountInfo *v2.AccountInfo, configuredOrgs []string) (*createUserParams, error) { pMap := accountInfo.Profile.AsMap() - org, ok := pMap["org"].(string) - if !ok || org == "" { + + // Use org from account info profile if provided, otherwise fall back to the connector's configured org. + org, _ := pMap["org"].(string) + if org == "" && len(configuredOrgs) > 0 { + org = configuredOrgs[0] + } + if org == "" { return nil, fmt.Errorf("org is required") }