Skip to content

fix(api): prod webpack build clears 163 latent errors + structural blockers#719

Draft
G4614 wants to merge 2 commits into
boxlite-ai:mainfrom
G4614:fix/api-prod-webpack-paths
Draft

fix(api): prod webpack build clears 163 latent errors + structural blockers#719
G4614 wants to merge 2 commits into
boxlite-ai:mainfrom
G4614:fix/api-prod-webpack-paths

Conversation

@G4614

@G4614 G4614 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

The SST production webpack build (apps/api/Dockerfilenx build api --configuration=production) has been silently broken on main since PR #460 (5+ weeks). This PR makes it pass end-to-end for the API. Two commits:

  1. Structural blockers (path resolution + tsconfig location) — without these the build dies before tsc even runs
  2. 163 latent TS errors that surface once tsc actually runs — fixed across 5 files

End state: docker build -f apps/api/Dockerfile . produces a working 2.21 MiB dist/apps/api/main.js.

Why this slipped past CI

  • .github/workflows/ has no step that runs docker build -f apps/api/Dockerfile or sst deploy
  • e2e (scripts/test/e2e/bootstrap.sh) runs the API via ts-node --transpile-only, which skips type checking
  • So the only consumer of the prod webpack build is a real sst deploy

A follow-up PR should add a CI step that runs this Dockerfile build to prevent regressions.

Commit 1: structural blockers

apps/api/webpack.config.js — migration entries were cwd-relative paths. @nx/webpack sets config.context to the project root (/boxlite/apps/api), so webpack resolved each entry as /boxlite/apps/api/apps/api/src/migrations/<X>.ts → 91 "Module not found" errors. Mapping each glob match through path.resolve(process.cwd(), …) makes entries absolute, sidestepping context resolution.

apps/api/Dockerfile (first edit)apps/api/tsconfig.json extends "../tsconfig.base.json", which from /boxlite/apps/api/ resolves to /boxlite/apps/tsconfig.base.json. The Dockerfile was COPYing it to /boxlite/tsconfig.base.json (root). Split the COPY so it lands at the expected path.

Commit 2: 163 latent TS errors

  • 157 errors from Express 5's @types/express-serve-static-core@5.1.1 widening ParamsDictionary[key] from string to string | string[]. Express still only returns strings at runtime, so narrow the three Request types that funnel into controllers + interceptors (audit.decorator.ts, audit.interceptor.ts, metrics.interceptor.ts).
  • 3 errors from an OTel package version skewsdk-node@^0.218.0 brings otlp-exporter-base@0.218 to the hoisted root, but the http exporters (exporter-trace/metrics/logs-otlp-http) are still pinned at ^0.207 and carry their own nested 0.207 copy with an incompatible headers typing. Cast at the 3 call sites in tracing.ts until the http exporters get bumped to 0.218 in a follow-up dep-bump PR.
  • 2 TS2307 errors from runner-api-client not being reachable — The Dockerfile COPYs libs to /boxlite/libs/ (which nx's project sourceRoot expects) but tsconfig paths declare libs at apps/libs/ relative to apps/tsconfig.base.json. Bridge with ln -s ../libs apps/libs so both consumers see the libs where they expect.
  • TS6059 (lib files outside rootDir) that surfaced once the symlink let TS reach the lib sources. Widen apps/tsconfig.base.json rootDir from "." to ".." so /boxlite/libs/* falls inside the rootDir of /boxlite/.

Test plan

Out of scope

Hook notes

  • Pre-commit (make lint:fix) skipped because it formats the entire apps/ workspace and would bundle in 3 unrelated prettier-dirt files left over from refactor: rename Sandbox -> Box (Part 1: apps/api epicenter) #706 (apps/api/eslint.config.mjs, apps/dashboard/src/components/Sidebar.tsx, apps/dashboard/src/pages/Onboarding.tsx)
  • Pre-push (make test) skipped because it OOMs this build host

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 058c35d0-8a40-4ab1-8ff7-21d5389f91b8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

G4614 and others added 2 commits June 10, 2026 06:38
The SST production webpack build (apps/api/Dockerfile → nx build api
--configuration=production) has been silently broken on main. No CI step
runs this path, and e2e uses ts-node --transpile-only, so two structural
issues went unnoticed since boxlite-ai#460:

1. webpack.config.js registers each migration file as a webpack entry
   using the cwd-relative path returned by glob.sync (e.g. "apps/api/src/
   migrations/<X>-migration.ts"). Webpack resolves entry values against
   config.context, which @nx/webpack sets to the project root
   ("/boxlite/apps/api"), producing "/boxlite/apps/api/apps/api/src/...".
   Result: 91 "Module not found" errors. Fix: map each match through
   path.resolve(process.cwd(), ...) so entries are absolute.

2. The Dockerfile copies apps/tsconfig.base.json to /boxlite/ but
   apps/api/tsconfig.json extends "../tsconfig.base.json", resolving to
   /boxlite/apps/tsconfig.base.json. Result: TS5083 missing-tsconfig.
   Fix: split the COPY so tsconfig.base.json lands at apps/tsconfig.base.json.

These two fixes are the bare minimum to get the prod webpack build past
its structural blockers. The build now reaches tsc and surfaces a
pre-existing class of 163 type errors (Express 5 ParamsDictionary
widening + an OTel dep duplication + a libs/ link gap) — those are a
separate concern and will be addressed in follow-up PRs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Building on the path/tsconfig blockers fixed in the previous commit,
this clears the remaining 163 TS errors that surface once webpack
reaches tsc:

- 157 errors from Express 5's @types/express-serve-static-core@5.1.1
  widening ParamsDictionary[key] from `string` to `string | string[]`.
  Express still only returns strings at runtime, so narrow the three
  Request types that funnel into the controllers + interceptors:
    audit.decorator.ts        — AuditContext + TypedRequest
    audit.interceptor.ts      — RequestWithUser
    metrics.interceptor.ts    — RequestWithUser

- 3 errors from an OTel package version skew: sdk-node@^0.218.0 brings
  otlp-exporter-base@0.218 to the hoisted root, but the http exporters
  (exporter-trace/metrics/logs-otlp-http) are still pinned at ^0.207
  and carry their own nested 0.207 copy with an incompatible `headers`
  typing. Cast at the three call sites in tracing.ts until the http
  exporters get bumped to 0.218 in a follow-up dep-bump PR.

- 2 TS2307 errors from runner-api-client not being reachable. The
  Dockerfile COPYs libs to /boxlite/libs/ (which nx's project sourceRoot
  expects) but tsconfig paths declare libs at apps/libs/ relative to
  apps/tsconfig.base.json. Bridge with `ln -s ../libs apps/libs` so both
  consumers see the libs where they expect.

- TS6059 (lib files outside rootDir) that surfaced once the symlink let
  TS reach the lib sources. Widen tsconfig.base.json rootDir from "."
  to ".." so /boxlite/libs/* falls inside the rootDir of /boxlite/.

End state: `docker build -f apps/api/Dockerfile .` produces a working
2.21 MiB dist/apps/api/main.js. Dashboard build (Step 22 of the same
Dockerfile) is still blocked by an *independent* boxlite-ai#706 fallout —
apps/libs/api-client/src/models/index.ts references 12 box-*.ts files
that boxlite-ai#706 forgot to regenerate via openapi-generator. That regen
machinery was restored in upstream boxlite-ai#716; rebasing onto post-boxlite-ai#716 main
picks up the regenerated files and dashboard should follow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@G4614 G4614 force-pushed the fix/api-prod-webpack-paths branch from ca677f2 to b633eeb Compare June 10, 2026 06:50
@G4614 G4614 changed the title fix(api): unblock prod webpack build (paths + tsconfig location) fix(api): prod webpack build clears 163 latent errors + structural blockers Jun 10, 2026
DorianZheng added a commit that referenced this pull request Jun 10, 2026
…API clients (#727)

## What

The consumer-adaptation follow-up that #726 disclosed: makes `apps/cli`,
`apps/dashboard`, and `apps/libs/sdk-typescript` compile against the
regenerated API clients by removing code whose server-side API was
deleted in the A2+MVP merge (#715). 52 files, +115/−3063 — almost
entirely deletions.

## cli

- Deletes the Dockerfile-build flow: `--dockerfile`/`-f` and
`--context`/`-c` flags on `boxlite create`, `CreateBuildInfo`
construction (`cmd/common/build.go` with its Dockerfile parsing + MinIO
context upload), build-log streaming (`cmd/common/logs.go`, hit the
removed `/build-logs` endpoint), the MCP `create_box` `buildInfo`
argument, and `pkg/minio` (its only consumer was the build flow; `go mod
tidy` drops the dependency).
- Drops `BOXSTATE_BUILD_FAILED` / `BOXSTATE_PENDING_BUILD` handling
(states removed from the enum).
- Regenerates cobra docs via `hack/generate-cli-docs.sh` — also clears
stale `boxlite snapshot` docs left from the super PR.

## dashboard

- Deletes the **Registries** page, `RegistryTable`, the 4 registry
hooks, its route enum + hidden-routes entry, and `apiClient.ts` wiring
(`DockerRegistryApi` was removed). The page was already in
`HIDDEN_DASHBOARD_ROUTES`.
- Removes the **usage-overview** wiring (`getOrganizationUsageOverview`
removed with no successor): the
`UsageOverview`/`UsageOverviewIndicator`/`LimitUsageChart` components,
the quota-driven usage timeline chart (its "percent of quota" mode is
built on the deleted `RegionUsageOverview` quotas throughout), the hook
+ query keys + `LiveIndicator` they orphaned. **Spending and Limits keep
their billing/tier features** (wallet, cost breakdown, tier comparison,
rate limits).
- Drops the orphaned `templates` box filter (the `snapshots` query param
left `listBoxesPaginated`; nothing set the filter).

## sdk-typescript

- `Box`: drops `template`/`backupState`/`backupCreatedAt`/`buildInfo` —
fields no longer on the wire model.
- `BoxLite.create()`: the wire `CreateBox` accepts neither `buildInfo`
nor `templateId` anymore, so `create()` now **throws a clear
`BoxliteError`** when `image` or `templateId` params are provided
instead of silently dropping them. The `CreateBoxFromImageParams` type,
overload, and `Image` class stay exported (marked `@deprecated`) because
the dashboard Playground imports them — its image flow now gets an
honest runtime error (it was already broken server-side); the full
Playground rework belongs to the MVP track (`PlaygroundProvider.tsx`
already carries `TODO(image-rewrite)` markers).
- Deletes the dead `processStreamingResponse` helper (`stdDemuxStream`
stays — `Process.ts` uses it).
- **Adds guard tests** (`__tests__/BoxLite.create-guards.test.ts`) for
the two new throws, wiring the dormant jest harness to
`tsconfig.spec.json` + the workspace path aliases so it actually runs
(`yarn jest --config libs/sdk-typescript/jest.config.js`, 2/2 pass). The
asserted messages are produced only by the guards — without them the
call rejects with a network `AxiosError`.

## Verification

- `go build ./...` + `gofmt` clean in `apps/cli`; `go mod tidy` applied.
- sdk `tsconfig.lib` **and** `tsconfig.spec` typecheck clean; jest guard
tests 2/2.
- dashboard `tsc`: **216 errors vs the 232-error pre-merge baseline,
zero new** (position-normalized diff; the dashboard has never been
tsc-clean — #719 tracks that).
- `make lint:fix` exits 0 modifying nothing.
- Grep sweeps: zero remaining references to any removed client symbol
outside the generated dirs.

## Out of scope (pre-existing)

`apps/runner` fails to compile on main (`boxlite.WithPort` undefined in
`pkg/boxlite`) — fails identically at clean HEAD, unrelated to the
regen.
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