Skip to content

Conversation

@sicarius97
Copy link

@sicarius97 sicarius97 commented Sep 11, 2025

Adds a new custom oauth provider for netsuite


Important

Introduces NetSuite as a new OAuth provider, updating relevant schemas and configurations to support it.

  • Behavior:
    • Adds NetSuiteProvider class in netsuite.tsx to handle OAuth with NetSuite, including token fetching and user info processing.
    • Updates getProvider() in index.tsx to support netsuite as a provider type.
    • Adds netsuiteAccountId handling in createOrUpdateProjectWithLegacyConfig() in projects.tsx.
  • Schemas:
    • Adds netsuiteAccountId to environmentConfigSchema in schema.ts.
    • Updates oauthProviderReadSchema and oauthProviderWriteSchema in projects.ts to include netsuite_account_id.
    • Adds oauthNetSuiteAccountIdSchema in schema-fields.ts.
  • Misc:
    • Adds netsuite to standardProviders in oauth.tsx.

This description was created by Ellipsis for 47025b5. You can customize this summary. It will automatically update as commits are pushed.

Review by RecurseML

🔍 Review performed on 5da45d8..47025b5

Severity Location Issue Action
Medium packages/stack-shared/src/config/schema.ts:205 Naming inconsistency between schema property and API interface Dismiss
Medium packages/stack-shared/src/interface/crud/projects.ts:25 Object property using snake_case instead of camelCase in TypeScript code Dismiss
✅ Files analyzed, no issues (3)

apps/backend/src/oauth/providers/netsuite.tsx
apps/backend/src/oauth/index.tsx
apps/backend/src/lib/projects.tsx

⏭️ Files skipped (trigger manually) (2)
Locations Trigger Analysis
packages/stack-shared/src/schema-fields.ts Analyze
packages/stack-shared/src/utils/oauth.tsx Analyze

Need help? Join our Discord

Summary by CodeRabbit

  • New Features

    • NetSuite added as a supported OAuth provider for sign-in, including token validation and user profile retrieval.
    • Dashboard: NetSuite provider option with an "Account ID" field and NetSuite branding (icon, title, color).
  • Chores

    • NetSuite added to the standard provider list.
    • Configuration schemas, interfaces, and defaults updated to accept and validate a NetSuite Account ID.
  • Tests

    • Updated tests to include NetSuite in allowed OAuth provider types.

sicarius97 and others added 4 commits September 10, 2025 21:19
- Implement NetSuite OAuth provider following existing patterns
- Add NetSuite to standardProviders list and OAuth registry
- Add netsuiteAccountId configuration field to schemas
- Support NetSuite's account-specific endpoints
- Include comprehensive documentation

NetSuite OAuth provider supports:
- OAuth 2.0 Authorization Code Grant flow
- Account-specific authorization and token endpoints
- User profile retrieval from NetSuite employee records
- Access token validation
- Configurable account ID via environment or config
Copilot AI review requested due to automatic review settings September 11, 2025 14:57
@vercel
Copy link

vercel bot commented Sep 11, 2025

@sicarius97 is attempting to deploy a commit to the Stack Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 11, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds NetSuite OAuth support across backend, shared schemas/types, dashboard UI, branding, and templates: new NetSuiteProvider, registration and payload wiring (netsuiteAccountId), schema and CRUD additions, UI form field and icon/color assets.

Changes

Cohort / File(s) Summary
NetSuite OAuth provider implementation
apps/backend/src/oauth/providers/netsuite.tsx
New NetSuiteProvider extending OAuthBaseProvider with create, postProcessUserInfo, and checkAccessTokenValidity; configures NetSuite endpoints/scopes, reads accountId from options or env, normalizes userinfo, and validates tokens.
Backend registration & project wiring
apps/backend/src/oauth/index.tsx, apps/backend/src/lib/projects.tsx
Registers "netsuite" in provider map; includes netsuiteAccountId in payload for standard provider creation; maps environment auth.oauth.providers.netsuiteAccountId to netsuite_account_id in project create/update.
Shared schemas, types & utils
packages/stack-shared/src/schema-fields.ts, packages/stack-shared/src/config/schema.ts, packages/stack-shared/src/interface/crud/projects.ts, packages/stack-shared/src/utils/oauth.tsx, packages/stack-shared/src/config/schema-fuzzer.test.ts
Adds oauthNetSuiteAccountIdSchema; exposes netsuiteAccountId on environment OAuth provider schema and org defaults; adds netsuite_account_id to CRUD schema; appends "netsuite" to standardProviders; adds fuzzing example for netsuiteAccountId.
Dashboard UI changes
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx
Adds netsuite title mapping, netsuiteAccountId to provider form schema and defaults, conditional Account ID input for netsuite, and includes netsuiteAccountId in update payload for standard providers.
Branding & icons
packages/stack-ui/src/components/brand-icons.tsx
Adds Netsuite SVG component, maps netsuite to the icon/title, and adds netsuite brand color (#403C38).
Template types
packages/template/src/lib/stack-app/project-configs/index.ts
Adds optional netsuiteAccountId?: string to AdminOAuthProviderConfig for standard providers.
Tests
apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts
Extends expected allowed provider types literal to include netsuite in a test assertion.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Backend as Backend OAuth Controller
  participant Provider as NetSuiteProvider
  participant NetSuite as NetSuite OAuth2

  Client->>Backend: Start OAuth (provider=netsuite)
  Backend->>Provider: create({ clientId, clientSecret, accountId })
  Note right of Provider `#DDEBEF`: Configure issuer, auth/token endpoints, scopes
  Backend->>NetSuite: Redirect user to Authorization Endpoint
  NetSuite-->>Client: Login & consent
  Client->>Backend: Callback with code
  Backend->>NetSuite: Token request (code)
  NetSuite-->>Backend: TokenSet (access_token, expires)
  Backend->>Provider: postProcessUserInfo(TokenSet)
  Provider->>NetSuite: GET /userinfo (Bearer)
  NetSuite-->>Provider: User info JSON (may include accountId)
  Provider-->>Backend: OAuthUserInfo (accountId, email, name)
  Backend-->>Client: Session established
Loading
sequenceDiagram
  autonumber
  participant Scheduler as Token Checker
  participant Provider as NetSuiteProvider
  participant NetSuite as NetSuite OAuth2

  Scheduler->>Provider: checkAccessTokenValidity(accessToken)
  Provider->>NetSuite: GET /services/rest/.../oauth2/v1/userinfo (Bearer)
  alt 200 OK
    NetSuite-->>Provider: 200 OK
    Provider-->>Scheduler: true
  else non-OK / error
    NetSuite--x Provider: Error/Non-OK
    Provider-->>Scheduler: false
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing focused review:
    • apps/backend/src/oauth/providers/netsuite.tsx — userinfo parsing for multiple response shapes, accountId validation, token expiry handling.
    • Consistency of netsuiteAccountId (camelCase) vs netsuite_account_id (snake_case) across backend mappings, shared schemas, and DB/project wiring.
    • Dashboard form conditional rendering and payload submission path.
    • Schema additions in shared package for backward compatibility and OpenAPI metadata.

Possibly related PRs

  • project owner team #835 — touches apps/backend/src/lib/projects.tsx and modifies createOrUpdateProjectWithLegacyConfig; likely related to wiring changes for provider mapping and payload shape.

Poem

I hop through scopes with gentle might,
I add an Account ID to make things right,
I fetch userinfo by token's light,
I draw a new icon in brand-true sight,
I nibble bugs and ship delight. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: introducing NetSuite as a new OAuth provider.
Description check ✅ Passed The description comprehensively covers the changes with clear sections on behavior, schemas, and misc updates, explaining the scope and rationale of the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c169493 and 0d05ba4.

📒 Files selected for processing (1)
  • apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Vercel Agent Review

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds NetSuite as a new OAuth provider to the Stack authentication system. It enables users to authenticate using their NetSuite accounts by implementing the necessary OAuth flow and configuration.

  • Adds "netsuite" to the list of standard OAuth providers
  • Implements NetSuite-specific OAuth provider with account ID configuration
  • Adds schema validation and configuration support for NetSuite account ID parameter

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/stack-shared/src/utils/oauth.tsx Adds "netsuite" to standardProviders array
packages/stack-shared/src/schema-fields.ts Defines schema validation for NetSuite account ID
packages/stack-shared/src/interface/crud/projects.ts Adds NetSuite account ID to OAuth provider schemas
packages/stack-shared/src/config/schema.ts Integrates NetSuite account ID into environment configuration
apps/backend/src/oauth/providers/netsuite.tsx Implements complete NetSuite OAuth provider class
apps/backend/src/oauth/index.tsx Registers NetSuite provider and handles configuration
apps/backend/src/lib/projects.tsx Maps NetSuite account ID in project configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds NetSuite as a new OAuth provider to the Stack Auth system. The implementation follows the established patterns used by other OAuth providers in the codebase, particularly those requiring additional configuration parameters like Microsoft (tenant ID) and Facebook (config ID).

The changes span multiple layers of the application:

Core Provider Implementation: A new NetSuiteProvider class extends OAuthBaseProvider with NetSuite-specific logic. The implementation handles NetSuite's unique OAuth characteristics, including account-specific endpoints (using the account ID in URLs like https://{accountId}.app.netsuite.com/app/login/oauth2/authorize.nl) and non-standard userinfo responses that can return either single records or arrays.

Schema and Configuration: The PR adds proper schema validation through oauthNetSuiteAccountIdSchema with Yup validation and OpenAPI documentation. The account ID field is integrated at the environment configuration level alongside other provider-specific parameters, with proper typing and default values.

Integration Points: NetSuite is added to the standardProviders array, making it available throughout the application wherever OAuth providers are enumerated. The provider is registered in the OAuth provider mapping with proper parameter passing for the account ID configuration.

Data Flow: The implementation includes robust user data extraction logic that handles NetSuite's variable response formats, with fallbacks for different response structures and comprehensive error handling when user information cannot be extracted.

This addition integrates seamlessly with the existing OAuth infrastructure, requiring no changes to core OAuth logic while properly handling NetSuite's enterprise-specific requirements.

Confidence score: 4/5

  • This PR is generally safe to merge with good implementation following established patterns
  • Score reflects the complexity of OAuth provider integration and the need for thorough testing of NetSuite-specific logic
  • Pay close attention to the user data extraction logic in apps/backend/src/oauth/providers/netsuite.tsx which handles multiple response formats

7 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/backend/src/oauth/providers/netsuite.tsx (2)

45-52: Consider adding retry logic for userinfo endpoint.

The userinfo endpoint fetch doesn't have any retry logic. NetSuite APIs can sometimes have transient failures, so consider adding retry logic similar to other OAuth providers in the codebase.


113-119: Consider adding specific error handling in checkAccessTokenValidity.

The current implementation returns false for any error, which could hide important issues. Consider logging errors or differentiating between network failures and authentication failures.

 async checkAccessTokenValidity(accessToken: string): Promise<boolean> {
   try {
     const res = await fetch(`https://${this.accountId}.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/userinfo`, {
       method: "GET",
       headers: {
         Authorization: `Bearer ${accessToken}`,
         "Content-Type": "application/json",
       },
     });
     return res.ok;
   } catch (error) {
+    // Log the error for debugging purposes while still returning false
+    console.error("Failed to validate NetSuite access token:", error);
     return false;
   }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5da45d8 and 47025b5.

📒 Files selected for processing (7)
  • apps/backend/src/lib/projects.tsx (1 hunks)
  • apps/backend/src/oauth/index.tsx (3 hunks)
  • apps/backend/src/oauth/providers/netsuite.tsx (1 hunks)
  • packages/stack-shared/src/config/schema.ts (2 hunks)
  • packages/stack-shared/src/interface/crud/projects.ts (1 hunks)
  • packages/stack-shared/src/schema-fields.ts (1 hunks)
  • packages/stack-shared/src/utils/oauth.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer ES6 Map over Record when representing key–value collections

Files:

  • packages/stack-shared/src/schema-fields.ts
  • packages/stack-shared/src/utils/oauth.tsx
  • packages/stack-shared/src/interface/crud/projects.ts
  • apps/backend/src/lib/projects.tsx
  • apps/backend/src/oauth/index.tsx
  • apps/backend/src/oauth/providers/netsuite.tsx
  • packages/stack-shared/src/config/schema.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Security Check
🔇 Additional comments (7)
packages/stack-shared/src/schema-fields.ts (1)

512-512: LGTM!

The NetSuite account ID schema is properly defined with appropriate OpenAPI metadata, including a clear description and example value. The placement follows the existing pattern by being positioned after the Microsoft tenant ID schema.

packages/stack-shared/src/utils/oauth.tsx (1)

1-1: LGTM!

NetSuite is correctly added to the standardProviders array, maintaining alphabetical order and following the established pattern for OAuth providers.

apps/backend/src/lib/projects.tsx (1)

186-186: LGTM!

The NetSuite account ID is properly mapped from the provider configuration to the environment config override, maintaining consistency with other provider-specific fields like facebookConfigId and microsoftTenantId.

apps/backend/src/oauth/index.tsx (1)

17-17: LGTM!

NetSuite provider is correctly integrated into the OAuth system:

  • Import statement follows the established pattern
  • Provider is registered in the _providers mapping
  • Account ID is properly passed to the provider's create method in the standard flow

Also applies to: 35-35, 83-83

packages/stack-shared/src/interface/crud/projects.ts (1)

25-25: LGTM!

The netsuite_account_id field is correctly added to the OAuth provider read schema, following the established pattern and using the appropriate optional schema.

packages/stack-shared/src/config/schema.ts (1)

205-205: LGTM!

NetSuite account ID is properly integrated into the configuration schema:

  • Added to the environment config schema as an optional field (line 205)
  • Included in organization defaults with undefined as the default value (line 446)

Both changes follow the established patterns for provider-specific configuration fields.

Also applies to: 446-446

apps/backend/src/oauth/providers/netsuite.tsx (1)

31-32: No change required — NetSuite OAuth endpoints are correct.
Authorization endpoint https://${accountId}.app.netsuite.com/app/login/oauth2/authorize.nl (system.netsuite.com as fallback) and token endpoint https://${accountId}.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token are valid; some docs also show the token path under <ACCOUNT_ID>.app.netsuite.com.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx (1)

172-179: Add clarification to the Account ID label.

The "Account ID" label should specify when this field is required for NetSuite OAuth, similar to how the Facebook and Microsoft fields provide context. For example:

  • Facebook: "(only required for Facebook Business)"
  • Microsoft: "(required if you are using the organizational directory)"

Consider updating the label to clarify whether this is always required, optional, or conditionally required.

               {props.id === 'netsuite' && (
                 <InputField
                   control={form.control}
                   name="netsuiteAccountId"
-                  label="Account ID"
+                  label="Account ID (required for NetSuite OAuth)"
                   placeholder="Account ID"
                 />
               )}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81efa59 and a78c8dc.

📒 Files selected for processing (2)
  • apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx (5 hunks)
  • packages/stack-ui/src/components/brand-icons.tsx (13 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx (2)
packages/stack-shared/src/schema-fields.ts (1)
  • yupString (187-190)
apps/dashboard/src/components/form-fields.tsx (1)
  • InputField (64-102)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Vercel Agent Review
🔇 Additional comments (6)
packages/stack-ui/src/components/brand-icons.tsx (3)

198-237: LGTM!

The NetSuite icon component follows the established pattern used by other provider icons in this file. The implementation is clean and consistent.


283-285: LGTM!

The netsuite case is correctly added to the Mapping function and follows the same pattern as other providers.


306-306: LGTM!

The toTitle mapping uses the correct "NetSuite" capitalization.

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx (3)

45-45: LGTM!

The toTitle mapping correctly adds NetSuite with proper capitalization, consistent with the brand-icons.tsx file.


78-78: LGTM!

The default value extraction and submission payload correctly handle netsuiteAccountId, following the same pattern used for other optional provider-specific fields like facebookConfigId and microsoftTenantId.

Also applies to: 92-92


65-65: Naming consistency confirmed—code is correct.

The schema correctly uses netsuiteAccountId (camelCase) on the frontend. The mapping layer in apps/backend/src/lib/projects.tsx (line 186) properly converts from the API's snake_case format (netsuite_account_id in packages/stack-shared/src/interface/crud/projects.ts line 25) to the internal camelCase format. This follows the same pattern as existing fields like facebookConfigId and microsoftTenantId.

apple: '#000000',
twitch: '#ffffff'
twitch: '#ffffff',
netsuite: '#403C38'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

Verify the NetSuite brand color.

The color #403C38 appears to be a dark gray/brown. Please confirm this matches NetSuite's official brand guidelines to ensure consistent branding.


🌐 Web query:

What is the official NetSuite brand color hex code?

💡 Result:

NetSuite’s primary orange (brand) hex is #FF5200. [1][2]

Sources:
[1] NetSuite docs (color palette listing).
[2] Color reference for #FF5200.


Correct the NetSuite brand color to match official guidelines.

NetSuite's primary brand color is #FF5200, not the dark gray/brown #403C38 currently added on line 321. Update this to ensure consistent branding.

🤖 Prompt for AI Agents
In packages/stack-ui/src/components/brand-icons.tsx around line 321, the
NetSuite brand color is incorrectly set to '#403C38'; update that entry so
NetSuite's primary color is the official '#FF5200' (replace the current value
with '#FF5200') to ensure accurate branding.

Copy link

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

The NetSuite Account ID is missing from the API response conversion, causing the value to be lost when the dashboard reads the project configuration back from the server.

View Details
📝 Patch Details
diff --git a/apps/backend/src/lib/config.tsx b/apps/backend/src/lib/config.tsx
index 0838f3d4..1bf26c60 100644
--- a/apps/backend/src/lib/config.tsx
+++ b/apps/backend/src/lib/config.tsx
@@ -518,6 +518,7 @@ export const renderedOrganizationConfigToProjectCrud = (renderedConfig: Complete
         client_secret: oauthProvider.clientSecret,
         facebook_config_id: oauthProvider.facebookConfigId,
         microsoft_tenant_id: oauthProvider.microsoftTenantId,
+        netsuite_account_id: oauthProvider.netsuiteAccountId,
       } as const) satisfies ProjectsCrud["Admin"]["Read"]['config']['oauth_providers'][number];
     })
     .filter(isTruthy)

Analysis

NetSuite Account ID lost in API response conversion

What fails: renderedOrganizationConfigToProjectCrud() in apps/backend/src/lib/config.tsx omits netsuite_account_id from OAuth provider mapping, causing data loss when dashboard fetches project configuration

How to reproduce:

 
};

// Call conversion function
const result = renderedOrganizationConfigToProjectCrud(config);
console.log(result.oauth_providers[0].netsuite_account_id); // undefined

Result: NetSuite Account ID missing from API response - input netsuiteAccountId: 'TEST_ACCOUNT_123' becomes undefined in output netsuite_account_id field

Expected: NetSuite Account ID should be preserved in API response, similar to facebook_config_id and microsoft_tenant_id mappings on lines 519-520

Copy link

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

The renderedOrganizationConfigToProjectCrud function is missing the netsuite_account_id field when transforming OAuth provider configuration from internal format back to the API format. This causes NetSuite account IDs to be silently dropped from API responses.

View Details
📝 Patch Details
diff --git a/apps/backend/src/lib/config.tsx b/apps/backend/src/lib/config.tsx
index 0838f3d4..1bf26c60 100644
--- a/apps/backend/src/lib/config.tsx
+++ b/apps/backend/src/lib/config.tsx
@@ -518,6 +518,7 @@ export const renderedOrganizationConfigToProjectCrud = (renderedConfig: Complete
         client_secret: oauthProvider.clientSecret,
         facebook_config_id: oauthProvider.facebookConfigId,
         microsoft_tenant_id: oauthProvider.microsoftTenantId,
+        netsuite_account_id: oauthProvider.netsuiteAccountId,
       } as const) satisfies ProjectsCrud["Admin"]["Read"]['config']['oauth_providers'][number];
     })
     .filter(isTruthy)

Analysis

Missing netsuite_account_id field in OAuth provider configuration transformation

What fails: The renderedOrganizationConfigToProjectCrud function in apps/backend/src/lib/config.tsx is missing the netsuite_account_id field when transforming internal OAuth provider configuration (using camelCase netsuiteAccountId) back to API response format (using snake_case).

How to reproduce:

  1. Configure a NetSuite OAuth provider with an account ID via the API or admin dashboard
  2. Call the GET project endpoint to retrieve the configuration
  3. The netsuite_account_id field will be missing from the OAuth provider configuration in the response

Result: The netsuite_account_id field is silently omitted from the API response even when it was previously configured in the internal configuration, causing data loss and preventing clients from retrieving their NetSuite OAuth configuration.

Expected: The netsuite_account_id field should be included in the OAuth provider configuration response, consistent with how facebook_config_id and microsoft_tenant_id are already being included.

Fix: Added the missing field mapping in the OAuth provider transformation object at line 520 of apps/backend/src/lib/config.tsx:

  • Added netsuite_account_id: oauthProvider.netsuiteAccountId to the transformation object

This ensures NetSuite account IDs are properly returned by the API, matching the behavior of other OAuth provider-specific fields defined in the schema (packages/stack-shared/src/interface/crud/projects.ts:25).

@vercel
Copy link

vercel bot commented Nov 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
stack-backend Ready Ready Preview Comment Nov 14, 2025 11:56pm
stack-dashboard Ready Ready Preview Comment Nov 14, 2025 11:56pm
stack-demo Ready Ready Preview Comment Nov 14, 2025 11:56pm
stack-docs Ready Ready Preview Comment Nov 14, 2025 11:56pm

@BilalG1 BilalG1 requested a review from N2D4 November 14, 2025 23:46
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.

2 participants