Skip to content

fix(settings): keep the server Supabase client out of Roles & access, so the web build passes - #1796

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/plan-row-client-safe
Oct 29, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/plan-row-client-safe

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

main's web build has failed since #1780 (e2587ed, 17:05 UTC), so no web change merged since then can deploy. CI on main shows web — format, lint & typecheck failing at Next.js production build:

You're importing a module that depends on "next/headers" … ./src/lib/supabase/server.ts

Why

Each PR built on its own, and the chain only formed once both were on main.

Fix

  • New lib/guards/plan-row.ts: ORG_PLAN_COLUMNS, planFromOrgRow and usagePlanFromOrgRow move here, with no database client and nothing else changed.
  • plan-guard.ts: re-exports them, so every server caller (and every test that mocks plan-guard) is unchanged.
  • plan-facts.ts: imports from plan-row.
  • New plan-row.test.ts: walks the imports of every 'use client' file (stopping at 'use server' modules, skipping type-only imports) and fails if one reaches lib/supabase/server.ts. With the old import it lists exactly this chain.

Related issue

Fixes main's build, broken by #1780 meeting #1776.

Type of change

  • fix — Bug fix

How to test

  1. cd web && yarn build. It passes; on main it fails with the error above.
  2. yarn vitest run src/lib/guards src/lib/chat.
  3. Settings › Roles & access still shows the plan and access lines.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Web: lint and tests pass (src/lib/guards, src/lib/chat, prompt.test.ts, chat-access: 18 files, 347 tests)
  • Tests added

Local build and typecheck: running; CI on this PR runs the same production build.

🤖 Generated with Claude Code

… so the web build passes

Settings › Roles & access (ansvisor#1780) imports lib/chat/access.ts, which reads
plan-facts.ts, which imported planFromOrgRow from plan-guard.ts, and
plan-guard.ts imports the server's Supabase client (next/headers). The
production build fails on that since ansvisor#1780 met ansvisor#1776 on main. The row-to-plan
reads move to plan-row.ts, with no database client; plan-guard re-exports them.
A test walks every 'use client' file's imports and fails if one reaches
lib/supabase/server.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. Moving the row-to-plan reads into plan-row.ts, with no database client, keeps the server Supabase client out of the client bundle that Settings › Roles & access pulls in through lib/chat/access.ts → plan-facts.ts; plan-guard.ts re-exports them, so server callers are unchanged. The new plan-row.test.ts walks the imports from every client file and fails on a path to lib/supabase/server.ts. On today's main (Wix, #1751 and the fan-out PRs included) web typecheck is clean and the guards and Chat tests pass.

@gkhngyk
gkhngyk merged commit 9e0e67b into ansvisor:main Oct 29, 2026
4 of 5 checks passed
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.

2 participants