Skip to content

chore(deps): upgrade api to next@16.3.0 - #811

Merged
sweetmantech merged 3 commits into
mainfrom
chore/next-16-3-upgrade
Aug 5, 2026
Merged

sweetmantech merged 3 commits into
mainfrom
chore/next-16-3-upgrade

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Part of recoupable/app#1929 (PR 1 of 8). This is the fleet's canary: api is the only one of the three frontends that needs no lint or build-system work first, so it isolates "does 16.3 break us" from "is our tooling broken."

Draft. The canary did its job and found a real blocker: 16.3 changes which files next build type-checks, which surfaces 203 pre-existing test-fixture errors and fails the deploy. Full diagnosis in this comment. Needs a decision before it can land.

What changed

  • next 16.0.10 → 16.3.0, react/react-dom 19.2.1 → 19.2.8 (16.3 release notes).
  • Removed eslint-config-next@15.1.7. It was dead weight, not something to upgrade: eslint.config.js builds its own flat config out of @typescript-eslint, prettier, jsdoc, and import, and never extends the Next config or loads @next/eslint-plugin-next. The only mention anywhere in the repo was the package.json line this PR deletes.
  • Committed the <!-- BEGIN:nextjs-agent-rules --> block that next dev writes into AGENTS.md on Next 16.2+. Per the upgrade guide, next dev re-adds it on every run, so committing it is what keeps the tree clean.

What we get for free, with no application code changes: Turbopack disk caching for next build, up to 90% less dev-server memory, and native Node.js streams in the App Router render path (~22% more requests under load per Vercel's benchmarks).

Verification

Gate Before (16.0.10) After (16.3.0)
pnpm test 797 files / 4329 tests passed 797 files / 4329 tests passed ✅ no change
pnpm lint:check — 0 errors, 2 warnings (both pre-existing unused eslint-disable directives) ✅
pnpm exec tsc --noEmit 236 unique errors 203 unique errors ✅ 33 fixed, 0 introduced
next build type check passes fails, 203 errors ❌ blocker
Preview deploy — state=failure ❌ blocked by the above

The blocker. 16.3 changes the default type checker to the project-local tsc CLI, which per useTypeScriptCli checks "the complete project selected by the configured tsconfig file […] including test files." tsconfig.json here is "include": ["**/*.ts", ...], so every __tests__/** file is now in the build's type check for the first time. The errors are pre-existing fixture drift, not regressions — normalized to file(line,col): error TSxxxx, this bump introduces 0 new ones and fixes 33.

Two ways forward, costed very differently — see the diagnosis comment for the options. Holding here rather than picking one unilaterally, since it sets this repo's type-checking posture.

Notes

  • pnpm add reports x402-next@0.7.3 has an unmet peer next@^15.0.0. This is not new — that peer was already unmet on 16.0.10, since the package pins the v15 major. Flagging it because the last PR in this fleet renames middleware.ts → proxy.ts, which touches the same x402 payment path.
  • next dev on this branch emits ⚠ The "middleware" file convention is deprecated. Please use "proxy" instead. Tracked separately in chat#1929, sequenced last because it is the only change in the fleet touching a live payment path.
  • api has no build workflow in CI (format.yml, lint.yml, test.yml only), and none of the last 40 merged PRs touched package.json — which is how the type drift accumulated unnoticed.

🤖 Generated with Claude Code

Bumps next 16.0.10 -> 16.3.0 and react/react-dom 19.2.1 -> 19.2.8.
16.3 brings Turbopack disk caching for `next build`, memory eviction in
dev, and native Node.js streams in the App Router render path.

Also drops `eslint-config-next` (15.1.7). It is a dead dependency here:
`eslint.config.js` builds its own flat config from @typescript-eslint,
prettier, jsdoc and import, and never references the Next config or
@next/eslint-plugin-next. Nothing but package.json mentioned it.

Commits the `<!-- BEGIN:nextjs-agent-rules -->` block that `next dev`
writes into AGENTS.md on 16.2+. It points agents at version-matched docs
in node_modules/next/dist/docs/, and `next dev` re-adds it on every run,
so committing it is what keeps the tree clean.

Tracked in recoupable/app#1929.
@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
api Ready Ready Preview Aug 5, 2026 4:33am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (5)
  • AGENTS.md is excluded by none and included by none
  • next.config.ts is excluded by none and included by none
  • package.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by none
  • tsconfig.build.json is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 61d24444-3799-46a6-9904-25d01b0b4a7b

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

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.

cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Aug 4, 2026

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Dev as Developer
    participant CLI as next dev / next build
    participant Agent as AI Agent Docs
    participant Lint as ESLint Flat Config
    participant TSC as TypeScript Compiler
    participant App as App Router
    participant NodeStream as Native Node.js Streams
    participant Cache as Turbopack Disk Cache

    Note over Dev,Cache: Runtime interactions after next@16.3.0 upgrade

    Dev->>CLI: Run next dev
    CLI->>Agent: NEW: Write agent rules block to AGENTS.md
    Agent-->>CLI: Committed block keeps tree clean

    Dev->>CLI: Run next build
    CLI->>Cache: Use Turbopack disk cache
    Cache-->>CLI: Reuse cached build artifacts

    Dev->>Lint: Run pnpm lint:check
    Lint->>Lint: Resolve from @typescript-eslint, prettier, jsdoc, import only
    Note over Lint: eslint-config-next removed (was unused)

    Dev->>TSC: Run pnpm exec tsc --noEmit
    TSC->>TSC: 33 type errors fixed by react@19.2.8
    alt Pre-existing errors in __tests__
        TSC->>TSC: 203 drift errors remain (out of scope)
    end

    CLI->>App: Serve requests
    App->>NodeStream: NEW: Use native Node.js streams
    Note over App,NodeStream: ~22% more requests under load

    App->>Cache: Cache rendered pages
    Cache-->>App: Up to 90% less dev-server memory
Loading

Auto-approved: Focused dependency upgrade (next 16.0.10→16.3.0, react 19.2.1→19.2.8) with no application code changes; tests and lint pass; unused dependency removed. No operational or behavioral tradeoff to decide.

Re-trigger cubic

@sweetmantech

Copy link
Copy Markdown
Contributor Author

Preview verification: ❌ deployment failed — and I got the cause wrong in the PR body above

Correcting the claim I made when opening this: I wrote that pnpm build "fails identically on main." That is wrong. I had baselined with tsc --noEmit, not next build, and the two do not check the same file set on 16.0.10. Body updated.

What actually happens

next build type check Result
main @ 16.0.10 passes build proceeds to page-data collection
this branch @ 16.3.0 fails, 203 errors build aborts, deploy fails

Preview deployment dpl_BEcd25A3ZHjB95HB2TE4Ss6mGh9P for 86b62c1 → state=failure, Command "pnpm run build" exited with 1, preceded by 203 error TS lines and Failed to type check.

Verified locally by reinstalling 16.0.10 from the lockfile on main with a cold tsconfig.tsbuildinfo: next build emits 0 error TS lines and gets all the way to Failed to collect page data for /api/accounts/id → Error: STRIPE_SK environment variable is required, which is just my local shell missing prod secrets. The type check passed.

Root cause

Next.js 16.3 changed the default type checker. Per useTypeScriptCli:

By default, next build runs the project-local tsc command instead of loading the TypeScript JavaScript compiler API. […] The complete project selected by the configured tsconfig file is checked, including test files and .next/dev/types when included.

api/tsconfig.json has "include": ["**/*.ts", ...] with "exclude": ["node_modules"], so the project selection sweeps in every __tests__/**. Next 16.0's compiler-API checker narrowed the set to app code; 16.3's tsc CLI does not.

So the 203 errors are pre-existing (they reproduce under pnpm exec tsc --noEmit on main — 236 there, and this bump actually fixes 33 of them), but 16.3 is the first version that lets them fail the build.

They are all fixture drift in test files, not app code: TriggerRun, EnrichedTask, AccountOrganization, Stripe's Subscription, and AI SDK's Tool have all moved on from what the mocks assert.

Why this was invisible until now

None of the last 40 merged PRs in this repo touched package.json. This is the first dependency change in months, which is why nothing has forced a fresh type check.

Not resolving this unilaterally

There are two defensible fixes and they differ by an order of magnitude in cost, so I am leaving this PR as-is pending a call:

  1. Scope the build's type check to app code — point typescript.tsconfigPath at a build tsconfig that excludes __tests__, restoring exactly the pre-16.3 build semantics. pnpm exec tsc --noEmit keeps checking tests, so nothing is hidden, and the 203 stay visible for a separate burn-down.
  2. Fix all 203 test-fixture errors — correct, but unrelated to this upgrade and far too large to fold in here.

Marking this draft until that is decided. pnpm test (797 files / 4329 tests) and pnpm lint:check remain green on this branch either way.

@sweetmantech
sweetmantech marked this pull request as draft August 4, 2026 15:11
Next 16.3 switched the default type checker to the project-local `tsc`
CLI. Per the useTypeScriptCli docs it checks "the complete project
selected by the configured tsconfig file ... including test files", where
16.0's compiler-API checker narrowed the set to app code.

tsconfig.json is `"include": ["**/*.ts"]`, so every __tests__ file entered
the build's type check for the first time and 203 pre-existing fixture
errors failed the build and the preview deploy. They are not regressions:
on main with 16.0.10 reinstalled and a cold tsbuildinfo, `next build`
emits 0 error TS lines, and this bump introduces 0 new errors while fixing
33 of them.

Points the build at a tsconfig.build.json that excludes test files, so the
build checks what it checked before. This is scoping, not silencing --
`pnpm exec tsc --noEmit` still uses the root tsconfig and still reports
all 203, which is where the burn-down will happen.

Verified: build compiles and type-checks with 0 errors, then stops at
`STRIPE_SK environment variable is required` collecting page data, which
is the same point main reaches locally. tsc --noEmit still reports 203.
Tests 797/797 files, 4329/4329.
@sweetmantech

Copy link
Copy Markdown
Contributor Author

Preview verification: ✅ green

Blocker resolved by scoping the build's type check back to app code (tsconfig.build.json + typescript.tsconfigPath). Preview for 61560e1 deployed successfully: https://api-n9csksfau-recoup.vercel.app

Build

Before the fix After
next build type errors 203 0
Compile aborted at type check ✓ Compiled successfully in 32.5s
Deploy state=failure state=success
pnpm exec tsc --noEmit 203 203 — unchanged, deliberately

That last row is the point: the errors are scoped out of the build, not out of existence. tsc --noEmit still reports every one, which is where the burn-down happens.

Locally the build now compiles, type-checks clean, and stops at Failed to collect page data for /api/accounts/[id] → STRIPE_SK environment variable is required — the exact point main on 16.0.10 reaches on a machine without prod secrets. Same behaviour as before the upgrade.

Live checks against the preview

# Check Expected Actual
1 GET /api/artists, no credentials 401 401 {"status":"error","error":"Exactly one of x-api-key or Authorization must be provided"} ✅
2 GET /api/artists?accountId=not-a-uuid (deliberate bad input) 4xx 401 — auth gate fires before validation, which is the correct order ✅
3 GET /api/definitely-not-a-route 404 404 ✅
4 CORS headers from next.config.ts headers() present access-control-allow-origin: *, access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS, PATCH ✅
5 GET /api/x402/image/generate?prompt=test, unpaid 402 challenge 402 {"x402Version":1,"error":"X-PAYMENT header is required","accepts":[{"scheme":"exact","network":"base","maxAmountRequired":"150000",…}]} ✅

Check 5 matters most: the x402 payment middleware still works on 16.3, returning the challenge with the right price (150000 = $0.15 at USDC's 6 decimals) and the description/schema from middleware.ts. That is the path the last PR in this fleet will rename to proxy.ts, so this is its baseline.

No secret or env value appears in any response body or header.

Suite

pnpm test 797 files / 4329 tests passed. pnpm lint:check 0 errors.

Marking ready for review.

@sweetmantech
sweetmantech marked this pull request as ready for review August 4, 2026 16:45

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 5 files

Confidence score: 3/5

  • In tsconfig.build.json, excluding tests from the build-time type check can hide fixture drift and test/type regressions that Next 16.3 correctly surfaced, increasing the chance of shipping mismatched assumptions that fail later in CI or runtime-like environments — restore test coverage in type-checking (or add an equivalent dedicated test tsconfig check in CI) before relying on this build config.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tsconfig.build.json">

<violation number="1" location="tsconfig.build.json:15">
P2: This new build-only tsconfig permanently removes the entire test suite from the production build's type check. The PR confirms that is exactly the 203-error 'fixture drift' that Next 16.3's build check surfaced, so after this change `next build` will go green while `tsc --noEmit` and the IDE keep reporting the same 203 diagnostics. That creates a confusing, durable two-standard signal (build green !== type-clean) and lets test/fixture type-drift silently accumulate again — the same class of undetected drift this upgrade was meant to surface. Consider fixing the underlying 203 errors rather than permanently excluding them, or at minimum narrowing the exclusion to the fixture files, and adding a build/CI invariant that guards against the two tsconfigs diverging.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant TS as tsconfig.json
    participant Build as tsconfig.build.json
    participant Next as next.config.ts
    participant BuildCLI as next build
    participant TSC as tsc CLI
    participant TestFiles as **/__tests__/**
    participant AppCode as src/** app code

    Note over Next,BuildCLI: Already-existing production build path (unchanged)

    Next->>BuildCLI: NEW: typescript.tsconfigPath = "tsconfig.build.json"
    BuildCLI->>Build: Read build-specific tsconfig
    
    alt With tsconfig.build.json
        Build->>Build: Extends tsconfig.json
        Build->>Build: Excludes __tests__ and *.test.ts
        Build-->>TSC: Only app code paths
        
        TSC->>AppCode: Type-check app source only
        AppCode-->>TSC: Type errors (pass/fail)
        TSC-->>BuildCLI: Compilation result
        BuildCLI-->>Next: Success/failure
        
    else Without tsconfig.build.json (default)
        Note over TSC,TestFiles: This is what 16.3 would do unconfigured
        BuildCLI->>TSC: Default: project-local tsc CLI
        TSC->>TS: Read root tsconfig.json
        TS->>TSC: include: ["**/*.ts", ...]
        TSC->>TestFiles: Also type-checks test files
        TSC->>AppCode: Type-checks app code
        TestFiles-->>TSC: 203 pre-existing fixture errors
        TSC-->>BuildCLI: Fail (203 errors)
        BuildCLI-->>Next: Build failure
    end

    Note over Next,BuildCLI: tsc --noEmit (CI / local dev) unchanged
    Note over TS,TSC: Still uses root tsconfig.json -- reports all 203 errors
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tsconfig.build.json
"See recoupable/chat#1929."
],
"extends": "./tsconfig.json",
"exclude": ["node_modules", "**/__tests__/**", "**/*.test.ts"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This new build-only tsconfig permanently removes the entire test suite from the production build's type check. The PR confirms that is exactly the 203-error 'fixture drift' that Next 16.3's build check surfaced, so after this change next build will go green while tsc --noEmit and the IDE keep reporting the same 203 diagnostics. That creates a confusing, durable two-standard signal (build green !== type-clean) and lets test/fixture type-drift silently accumulate again — the same class of undetected drift this upgrade was meant to surface. Consider fixing the underlying 203 errors rather than permanently excluding them, or at minimum narrowing the exclusion to the fixture files, and adding a build/CI invariant that guards against the two tsconfigs diverging.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tsconfig.build.json, line 15:

<comment>This new build-only tsconfig permanently removes the entire test suite from the production build's type check. The PR confirms that is exactly the 203-error 'fixture drift' that Next 16.3's build check surfaced, so after this change `next build` will go green while `tsc --noEmit` and the IDE keep reporting the same 203 diagnostics. That creates a confusing, durable two-standard signal (build green !== type-clean) and lets test/fixture type-drift silently accumulate again — the same class of undetected drift this upgrade was meant to surface. Consider fixing the underlying 203 errors rather than permanently excluding them, or at minimum narrowing the exclusion to the fixture files, and adding a build/CI invariant that guards against the two tsconfigs diverging.</comment>

<file context>
@@ -0,0 +1,16 @@
+    "See recoupable/chat#1929."
+  ],
+  "extends": "./tsconfig.json",
+  "exclude": ["node_modules", "**/__tests__/**", "**/*.test.ts"]
+}
</file context>

@cubic-dev-ai
cubic-dev-ai Bot dismissed their stale review August 4, 2026 16:59

Dismissed because Cubic found issues in a newer review.

@sweetmantech

Copy link
Copy Markdown
Contributor Author

Authenticated preview testing: ✅ all green

Follow-up to the earlier unauthenticated pass — this one exercises the authenticated surface, mutations, and framework-level behaviour.

Preview: https://api-n9csksfau-recoup.vercel.app
Deployment sha: 61560e1c — confirmed equal to this PR's head, not an earlier build.

A prod x-api-key 401s against previews (different key-hash salt), so I minted a throwaway key on the preview via the unauthenticated agent-onboarding route:

curl -sX POST "$PREVIEW/api/agents/signup" -H 'Content-Type: application/json' \
  -d '{"email":"agent+<ts>-<rand>@recoupable.com"}'   # → 200, account ccd69ed8…

1. Authenticated happy path

Endpoint Expected Actual
GET /api/accounts/id 200 200 {"status":"success","accountId":"ccd69ed8-…"} ✅
GET /api/artists 200 200 {"status":"success","artists":[]} ✅
GET /api/chats 200 200 ✅
GET /api/organizations 200 200 ✅
GET /api/tasks 200 200 ✅
GET /api/ai/models 200 200, full model catalogue ✅
GET /api/keys 401 401 "Authorization header with Bearer token required" ✅ by design — the route's JSDoc requires a Bearer token; an API key is correctly refused

2. Async dynamic params + full CRUD round-trip

This is the surface most likely to break on a Next 16.x bump (params is a Promise and must be awaited), so I drove a real record through it rather than reading empty collections:

Step Result
POST /api/artists {"name":"Next163 Preview Probe"} 201, artist f2751fe7-… created with account_info row ✅
GET /api/artists/{id}/socials 200 with pagination envelope ✅
GET /api/artists/{id}/posts 200 with pagination envelope ✅
PATCH /api/artists/{id} → rename 200, returns "Next163 Probe Renamed" ✅
GET /api/artists re-read rename visible in the list ✅ persisted
GET /api/accounts/{other-account-id} 403 "Access denied to specified account_id" ✅ access control intact
GET /api/artists/{id} 405 ✅ by design — that route exports only OPTIONS/DELETE/PATCH, no GET
DELETE /api/artists/{id} 200 {"success":true} ✅
GET /api/artists final {"artists":[]} ✅ test data removed, no residue

Create → read → update → verify → delete all work through params: Promise<{id}>.

3. Deliberate bad input, sent with a valid key

Re-run with credentials so these test body/query validation rather than just tripping the auth gate:

Probe Expected Actual
GET /api/artists/not-a-uuid/socials 400 400 {"missing_fields":["id"],"error":"id must be a valid UUID"} ✅
GET /api/accounts/not-a-uuid 400 400 same shape ✅
POST /api/artists with {} 400 400 {"missing_fields":["name"],"error":"name is required"} ✅
GET …/socials?limit=abc 400 400 "Invalid input: expected number, received NaN" ✅ Zod coercion intact
GET /api/artists with bogus key 401 401 "Unauthorized" ✅

4. Framework-level surfaces

Check Result
OPTIONS /api/artists preflight 200 with all three access-control-* headers from next.config.ts headers() ✅
POST /mcp tools/list 200, 39 tools (create_new_artist, get_artist_socials, select_catalogs, …) ✅
GET /mcp unauthenticated 401 ✅
Header leakage only access-control-*, x-matched-path, x-robots-tag — no secret or env value anywhere ✅

5. Preview vs production differential

Same requests against prod (still on 16.0.10) to separate a real regression from normal behaviour:

Path Preview (16.3.0) Prod (16.0.10)
GET /mcp no auth 401 401 same
GET /api/artists no auth 401 401 same
GET /api/definitely-not-real 404 404 same
/.well-known/workflow/v1/flow 404 404 same — not a 16.3 regression
/.well-known/workflow/v1/step 404 404 same
POST /mcp tools/list + preview key 200 401 expected — the key is preview-minted and prod uses a different hash salt, which is exactly why prod rejects it

Two things I initially recorded as failures and then disproved rather than reporting:

  • POST /api/mcp 404 — my path was wrong. The route is app/mcp/route.ts, mounted at /mcp, not under /api.
  • The .well-known/workflow 404s — identical on production, so the withWorkflow wrapper behaves no differently here.

Not covered

  • Stripe endpoints — previews carry live Stripe credentials, so I stayed off any path that could create a real charge or subscription.
  • /api/research/* — each call bills Songstats per hit. Skipped deliberately rather than burning margin on a smoke test.

Both are worth an eye during merge, since neither is exercised here.

Cleanup

Test artist deleted, /api/artists back to empty, and the minted key plus all response fixtures shredded from the scratchpad.

Nothing in this PR changes runtime behaviour — it is a version bump plus a build-time type-check scope — and the preview bears that out across auth, CRUD, validation, CORS, and MCP.

@sweetmantech
sweetmantech merged commit 91a1a3f into main Aug 5, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — b87aa236 Deployed Aug 5, 2026 by vercel[bot]
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