Skip to content

apps/api fails to boot from source: NestJS cannot resolve HybridAuthGuard dependency (self-hosting, v3.90.1) #3331

Description

@don-mishael

Issue Summary

When running Comp from source following the README "Development" steps, the NestJS API (apps/api) crashes on startup with a dependency-injection error:
NestJS cannot resolve ApiKeyService for HybridAuthGuard.
The Next.js app andportal start fine and the login page renders, but sign-in is blocked because the auth API never comes up (the browser auth client calls the API on port 3333, which is down).

The module wiring looks correct in source (AuthModule provides and exportsApiKeyService and HybridAuthGuard; SOAModule imports AuthModule), so this appears to be a runtime/build issue rather than a missing provider. I could not find an existing issue or docs describing the supported runtime for apps/api in self-hosting, so I am filing this to clarify the intended setup.

Steps to Reproduce

  1. git clone the repo at tag v3.90.1
  2. bun install
  3. Create .env files for packages/db, apps/app, apps/portal, apps/api (DATABASE_URL to an external Postgres 15, AUTH_SECRET/SECRET_KEY, Google OAuth creds, AWS S3 vars)
  4. bun run db:generate for apps/app, `apps/po
  5. Build the workspace packages: bunx turbo run build --filter='./packages/*'
  6. Start the API (nest start --watch, via the api dev script)

The README lists running the apps from source as the supported development path, and the API is required for authentication, but apps/api does not start on a clean checkout.

Actual Results

The API process crashes on bootstrap:
[NestFactory] Starting Nest application...
[ExceptionHandler] UnknownDependenciesException: Nest can't resolve dependencies of the HybridAuthGuard (?, Reflector). Please make sure that the argument ApiKeyService at index [0] is available

  • If ApiKeyService is a provider, is it part of the current SOAModule?

Runtime note: I tried both runtimes and got two

  • Under Node: the API fails earlier with SyntaxError: Unexpected token '<' from a workspace package subpath export (e.g. @trycompai/utils/devices), which appears to resolve to raw TypeScript sour
  • Under Bun: it gets past that and fails with the HybridAuthGuard DI error above, consistent with emitDecoratorMetadata not being applied the way NestJS DI expects.

Expected Results

apps/api starts cleanly on a fresh checkout following the documented dev steps, listens on port 3333, and /api/auth/* responds so that Google sign-in from the app (port 3000) completes.

Technical details

  • Tag: v3.90.1
  • Node.js: 20.x
  • Bun: 1.3.x
  • Postgres: 15 (external)
  • OS: Amazon Linux 2023, x86_64 (headless server)
  • Relevant source (appears correct):
    • apps/api/src/auth/hybrid-auth.guard.ts - @Injectable(), constructor (private readonly apiKeyService: ApiKeyService, private readonly reflector: Reflector)
    • apps/api/src/auth/auth.module.ts - provide ApiKeyServiceandHybridAuthGuard`
    • apps/api/src/soa/soa.module.ts - imports: [AuthModule]

Questions:

  • Is there a required package build step (all workspace subpath exports compiled to JS) before starting the API under Node?
  • Is a specific emitDecoratorMetadata / reflect-metadata / tsconfig setup required that the README does not currently mention?

Evidence

Tested on a clean checkout of v3.90.1 on an external Postgres 15, following the README dev steps above.

  • App and portal start and the login page renders self-hosted Comp AI "Get Started with Comp AI" / "Continue with Google" page).
  • API startup log shows the UnknownDependenciesException above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions