Skip to content

fix: new account creation stuck on terms and conditions#8900

Open
jianwei1 wants to merge 3 commits intomainfrom
jianweichong/nes-1482-google-account-creation-hangs-during-training-at-film
Open

fix: new account creation stuck on terms and conditions#8900
jianwei1 wants to merge 3 commits intomainfrom
jianweichong/nes-1482-google-account-creation-hangs-during-training-at-film

Conversation

@jianwei1
Copy link
Contributor

@jianwei1 jianwei1 commented Mar 23, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error messages during journey duplication operations with improved contextual information for better troubleshooting when issues occur.

@jianwei1 jianwei1 self-assigned this Mar 23, 2026
@linear
Copy link

linear bot commented Mar 23, 2026

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

Walkthrough

Enhanced error handling in the journey duplication resolver by adding contextual details to exception messages, including userId and user roles. Added diagnostic logging to the component calling the mutation to capture success/failure details for debugging purposes.

Changes

Cohort / File(s) Summary
Enhanced Error Context in Resolver
apis/api-journeys/src/app/modules/journey/journey.resolver.ts
Expanded FORBIDDEN error messages to include userId and user role information from team and journey associations. Modified non-unique-constraint error handling to throw structured GraphQLError with extensions containing error code, source journey ID, team ID, and original error details.
Added Diagnostic Logging
apps/journeys-admin/src/components/TermsAndConditions/TermsAndConditions.tsx
Wrapped journeyDuplicate mutation call with try/catch block to log mutation parameters and error details (name, message, GraphQL errors, network errors) to browser console.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: new account creation stuck on terms and conditions' directly addresses the main issue being resolved. The changes add comprehensive error logging and handling to the TermsAndConditions component and journey duplication logic, which are essential to diagnose and fix account creation flow issues.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jianweichong/nes-1482-google-account-creation-hangs-during-training-at-film

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.

@nx-cloud
Copy link

nx-cloud bot commented Mar 23, 2026

View your CI Pipeline Execution ↗ for commit 1879260

Command Status Duration Result
nx run journeys-admin-e2e:e2e ✅ Succeeded 32s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 10s View ↗
nx run-many --target=deploy --projects=journeys... ✅ Succeeded 3m 22s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-23 21:49:32 UTC

@stage-branch-merger
Copy link

I see you added the "on stage" label, I'll get this merged to the stage branch!

@github-actions github-actions bot requested a deployment to Preview - journeys-admin March 23, 2026 21:36 Pending
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 23, 2026 21:41 Inactive
@github-actions
Copy link
Contributor

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Tue Mar 24 10:46:17 NZDT 2026

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apis/api-journeys/src/app/modules/journey/journey.resolver.ts`:
- Around line 625-635: The GraphQL error messages currently include internal
identifiers and raw role lists (e.g., userId, duplicateJourney.team?.userTeams,
duplicateJourney.userJourneys) — change the resolver's error handling to remove
sensitive values from the client-facing message and instead log the full
diagnostic server-side; update the throw/new ApolloError (or equivalent) in the
method that references duplicateJourney to return a sanitized message like "user
is not allowed to duplicate journey" while sending the detailed context (userId,
role arrays, original error) to the server logger (processLogger/errorLogger)
for debugging.

In
`@apps/journeys-admin/src/components/TermsAndConditions/TermsAndConditions.tsx`:
- Around line 96-150: Remove or gate the temporary DIAG console logging in the
try/catch around the journeyDuplicate call: either delete all
console.log/console.error statements in the block that reference
ONBOARDING_TEMPLATE_ID, newTeam.id, result, and the error introspection
(graphQLErrors/networkError), or wrap them behind a development-only check
(e.g., if (process.env.NODE_ENV === 'development') or a feature flag) so the
mutation call (journeyDuplicate) and its error handling stay but verbose
diagnostics are not emitted in production.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c73cc35c-e700-4f0a-a348-8b07d14acc9c

📥 Commits

Reviewing files that changed from the base of the PR and between 4d185dd and 1879260.

📒 Files selected for processing (2)
  • apis/api-journeys/src/app/modules/journey/journey.resolver.ts
  • apps/journeys-admin/src/components/TermsAndConditions/TermsAndConditions.tsx

Comment on lines +625 to +635
`user is not allowed to duplicate journey (userId: ${userId}, teamRoles: [${
duplicateJourney.team?.userTeams
?.filter((ut) => ut.userId === userId)
.map((ut) => ut.role)
.join(',') ?? ''
}], journeyRoles: [${
duplicateJourney.userJourneys
?.filter((uj) => uj.userId === userId)
.map((uj) => uj.role)
.join(',') ?? ''
}])`,
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 | 🟠 Major

Avoid returning internal identifiers and raw error details to clients.

Line 625 and Line 771 now expose internal context (userId, role sets, source/team IDs, original error metadata, and raw error text) in GraphQL responses. That increases information disclosure risk and should stay server-side only.

🔧 Proposed hardening (keep diagnostics in server logs, return sanitized GraphQL errors)
-              throw new GraphQLError(
-                `user is not allowed to duplicate journey (userId: ${userId}, teamRoles: [${
-                  duplicateJourney.team?.userTeams
-                    ?.filter((ut) => ut.userId === userId)
-                    .map((ut) => ut.role)
-                    .join(',') ?? ''
-                }], journeyRoles: [${
-                  duplicateJourney.userJourneys
-                    ?.filter((uj) => uj.userId === userId)
-                    .map((uj) => uj.role)
-                    .join(',') ?? ''
-                }])`,
-                {
-                  extensions: { code: 'FORBIDDEN' }
-                }
-              )
+              throw new GraphQLError('user is not allowed to duplicate journey', {
+                extensions: { code: 'FORBIDDEN' }
+              })

@@
-          throw new GraphQLError(
-            `journeyDuplicate failed: ${err instanceof Error ? err.message : String(err)}`,
-            {
-              extensions: {
-                code: err?.extensions?.code ?? 'INTERNAL_SERVER_ERROR',
-                sourceJourneyId: id,
-                teamId,
-                originalError: err instanceof Error ? err.name : typeof err
-              }
-            }
-          )
+          throw new GraphQLError('journeyDuplicate failed', {
+            extensions: {
+              code: err?.extensions?.code ?? 'INTERNAL_SERVER_ERROR'
+            }
+          })

Also applies to: 770-780

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apis/api-journeys/src/app/modules/journey/journey.resolver.ts` around lines
625 - 635, The GraphQL error messages currently include internal identifiers and
raw role lists (e.g., userId, duplicateJourney.team?.userTeams,
duplicateJourney.userJourneys) — change the resolver's error handling to remove
sensitive values from the client-facing message and instead log the full
diagnostic server-side; update the throw/new ApolloError (or equivalent) in the
method that references duplicateJourney to return a sanitized message like "user
is not allowed to duplicate journey" while sending the detailed context (userId,
role arrays, original error) to the server logger (processLogger/errorLogger)
for debugging.

Comment on lines +96 to +150
// DIAGNOSTIC: Wrap in try-catch to see the exact error in browser console
try {
console.log('[DIAG] journeyDuplicate: calling with', {
templateId: ONBOARDING_TEMPLATE_ID,
teamId: newTeam.id
})
const result = await journeyDuplicate({
variables: {
id: ONBOARDING_TEMPLATE_ID,
teamId: newTeam.id
}
})
console.log('[DIAG] journeyDuplicate: SUCCESS', result.data)
} catch (error: unknown) {
console.error('[DIAG] journeyDuplicate: FAILED')
console.error(
'[DIAG] Error name:',
error instanceof Error ? error.name : 'unknown'
)
console.error(
'[DIAG] Error message:',
error instanceof Error ? error.message : String(error)
)
if (
error != null &&
typeof error === 'object' &&
'graphQLErrors' in error
) {
const gqlErrors = (
error as {
graphQLErrors: Array<{
message: string
extensions?: Record<string, unknown>
}>
}
).graphQLErrors
gqlErrors.forEach((gqlErr, i) => {
console.error(
`[DIAG] GraphQL error ${i}:`,
gqlErr.message,
gqlErr.extensions
)
})
}
if (
error != null &&
typeof error === 'object' &&
'networkError' in error
) {
console.error(
'[DIAG] Network error:',
(error as { networkError: unknown }).networkError
)
}
})
}
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

Remove or gate temporary DIAG console logging before merge.

This block logs detailed mutation diagnostics (teamId, GraphQL errors, network errors) directly in browser console. Keep the non-blocking behavior, but avoid shipping verbose diagnostic logs in production.

🧹 Minimal cleanup while preserving behavior
-        // DIAGNOSTIC: Wrap in try-catch to see the exact error in browser console
         try {
-          console.log('[DIAG] journeyDuplicate: calling with', {
-            templateId: ONBOARDING_TEMPLATE_ID,
-            teamId: newTeam.id
-          })
-          const result = await journeyDuplicate({
+          await journeyDuplicate({
             variables: {
               id: ONBOARDING_TEMPLATE_ID,
               teamId: newTeam.id
             }
           })
-          console.log('[DIAG] journeyDuplicate: SUCCESS', result.data)
-        } catch (error: unknown) {
-          console.error('[DIAG] journeyDuplicate: FAILED')
-          console.error(
-            '[DIAG] Error name:',
-            error instanceof Error ? error.name : 'unknown'
-          )
-          console.error(
-            '[DIAG] Error message:',
-            error instanceof Error ? error.message : String(error)
-          )
-          if (
-            error != null &&
-            typeof error === 'object' &&
-            'graphQLErrors' in error
-          ) {
-            const gqlErrors = (
-              error as {
-                graphQLErrors: Array<{
-                  message: string
-                  extensions?: Record<string, unknown>
-                }>
-              }
-            ).graphQLErrors
-            gqlErrors.forEach((gqlErr, i) => {
-              console.error(
-                `[DIAG] GraphQL error ${i}:`,
-                gqlErr.message,
-                gqlErr.extensions
-              )
-            })
-          }
-          if (
-            error != null &&
-            typeof error === 'object' &&
-            'networkError' in error
-          ) {
-            console.error(
-              '[DIAG] Network error:',
-              (error as { networkError: unknown }).networkError
-            )
-          }
-        }
+        } catch {
+          // Intentionally non-blocking: allow onboarding to continue
+          // even if template duplication fails.
+        }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/journeys-admin/src/components/TermsAndConditions/TermsAndConditions.tsx`
around lines 96 - 150, Remove or gate the temporary DIAG console logging in the
try/catch around the journeyDuplicate call: either delete all
console.log/console.error statements in the block that reference
ONBOARDING_TEMPLATE_ID, newTeam.id, result, and the error introspection
(graphQLErrors/networkError), or wrap them behind a development-only check
(e.g., if (process.env.NODE_ENV === 'development') or a feature flag) so the
mutation call (journeyDuplicate) and its error handling stay but verbose
diagnostics are not emitted in production.

@jianwei1 jianwei1 removed the on stage label Mar 23, 2026
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.

1 participant