Skip to content

fix(api,app): unblock onboarding frameworks list for users without active org#2622

Merged
tofikwest merged 1 commit intomainfrom
fix/onboarding-frameworks-available-500
Apr 21, 2026
Merged

fix(api,app): unblock onboarding frameworks list for users without active org#2622
tofikwest merged 1 commit intomainfrom
fix/onboarding-frameworks-available-500

Conversation

@tofikwest
Copy link
Copy Markdown
Contributor

@tofikwest tofikwest commented Apr 21, 2026

Summary

Fresh signups hitting the first onboarding step ("Which compliance frameworks do you need?") have been seeing an empty screen with a disabled Continue button. Customer Daniel Cooke reported a 500 on https://api.trycomp.ai/v1/frameworks/available, and I reproduced it in incognito with a brand-new email.

Root cause

  • 2026-04-17 (commit a81af3efb7) — The /v1/frameworks/available endpoint's signature was changed from findAvailable() to findAvailable(@OrganizationId() organizationId?: string) so custom frameworks could be scoped per-org.
  • @OrganizationId() throws a plain Error when request.organizationId is falsy.
  • @SkipOrgCheck() (already on this endpoint) correctly allows session-auth'd users with no active org through — HybridAuthGuard sets request.organizationId = '' in that case.
  • Empty string is falsy → @OrganizationId() throws → NestJS converts the generic Error to HTTP 500.
  • The ?: string in the signature shows the intent was optional, but the decorator didn't honor it — that contract isn't visible in the decorator's type signature.
  • Audited every other @SkipOrgCheck() endpoint in the API; this was the only one combining it with @OrganizationId().

The failure was invisible for 4 days because FrameworkSelection.tsx silently swallowed HTTP errors in its SWR fetcher — a 500 looked identical to "no frameworks available."

Changes

  • Add @OrganizationIdOptional() in apps/api/src/auth/auth-context.decorator.ts — returns string | undefined instead of throwing. Explicit, safe companion to @OrganizationId() for @SkipOrgCheck()-decorated endpoints.
  • Harden @OrganizationId() to throw InternalServerErrorException (typed, surfaced by Nest's exception filter, logged by monitoring) instead of a plain Error (opaque 500). The message points to @OrganizationIdOptional() so the next misuse is immediately diagnosable.
  • Swap the decorator on findAvailable. The service already handles undefined correctly.
  • Regression tests in frameworks.controller.spec.ts — one asserting the endpoint returns data when organizationId is undefined (the fresh-signup case), and one asserting it passes the id through when present.
  • Surface API errors in FrameworkSelection.tsx — fetcher now throws on non-OK responses; component renders a visible error + retry button. Prevents the next server-side failure from producing a silent blank screen.

Test plan

  • Typecheck passes (no new errors introduced — verified locally by stashing changes and confirming same pre-existing errors on main before/after)
  • apps/api unit tests pass (new findAvailable tests follow the exact pattern of the existing findAll tests)
  • Sign up a fresh user in incognito → reach "Which compliance frameworks do you need?" step → framework options render
  • Simulate a 500 on /v1/frameworks/available (e.g., by breaking the env var temporarily) → onboarding UI shows a visible error + retry button, not a blank screen
  • Existing user on /setup still sees frameworks (no regression for the with-org path)

🤖 Generated with Claude Code


Summary by cubic

Fixes a 500 that blocked onboarding by making /v1/frameworks/available work when the user has no active org. The UI now shows a clear error with a retry instead of a blank screen.

  • Bug Fixes
    • Added @OrganizationIdOptional() for @SkipOrgCheck() endpoints; returns string | undefined.
    • Updated @OrganizationId() to throw InternalServerErrorException with guidance to use the optional decorator when appropriate.
    • Switched findAvailable to use @OrganizationIdOptional().
    • FrameworkSelection.tsx: fetcher now throws on non-OK responses; renders error + retry UI.
    • Regression tests added for findAvailable with and without organizationId.

Written for commit 8fee034. Summary will update on new commits.

…tive org

The GET /v1/frameworks/available endpoint was changed on April 17 to read
@organizationId() from the request. That decorator throws when the user
has no active organization, producing HTTP 500 for every fresh signup on
the first onboarding step — even though @SkipOrgCheck() is specifically
meant to allow this case.

- Add @OrganizationIdOptional() for @SkipOrgCheck()-decorated endpoints
- Harden @organizationId() to throw InternalServerErrorException with a
  message pointing to the optional variant, so future misuse is visible
  in monitoring instead of a generic 500
- Swap findAvailable to use @OrganizationIdOptional()
- Add regression tests covering both no-org and with-org cases
- Surface API errors in FrameworkSelection.tsx so the next server-side
  failure doesn't produce a silent blank onboarding screen

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

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

Project Deployment Actions Updated (UTC)
app Building Building Preview, Comment Apr 21, 2026 4:55pm
comp-framework-editor Building Building Preview, Comment Apr 21, 2026 4:55pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
portal Skipped Skipped Apr 21, 2026 4:55pm

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

Auto-approved: Fixes critical onboarding 500 error. Adds a safe optional decorator for organization extraction and improves UI resilience. Well-tested and low risk.

@tofikwest tofikwest merged commit 4466792 into main Apr 21, 2026
9 of 11 checks passed
@tofikwest tofikwest deleted the fix/onboarding-frameworks-available-500 branch April 21, 2026 17:06
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.27.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants