Skip to content

feat(office-settings): read and write the platform settings in core.system_config - #31

Merged
thinkclay merged 1 commit into
mainfrom
fix/856-office-settings
Sep 22, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/856-office-settings

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Part of Scaffald/SaaS#856.

core.system_config has RLS off and grants nothing to authenticated, so any client reading it through PostgREST gets 42501 insufficient privilege. The admin geographic-settings screen read it directly and failed on every load — and its error path re-triggered the read, so it made roughly 35,000 requests per visit and never settled.

Widening the grant is the wrong fix: the table holds platform limits (storage caps, photo limits, the site-overlap threshold) that only the office role may read or change. The read moves behind a role-checked endpoint instead, like every other office screen.

Adds OfficeSettings with getGeographic() and updateGeographic() against /v1/office/settings/geographic, registered on the client as officeSettings and exporting GeographicSettings.

tsc --noEmit and pnpm build clean. The endpoint ships in the SaaS PR.

🤖 Generated with Claude Code

…ystem_config

`core.system_config` is service-role only: RLS is off and it grants nothing
to `authenticated`, so a client reading it through PostgREST gets 42501.
The admin geographic-settings screen did exactly that and failed on every
load. Widening the grant is the wrong fix — the table holds platform
limits only the office role may see — so the read moves behind a
role-checked endpoint like every other office screen.

`officeSettings.getGeographic()` / `.updateGeographic()` against
`/v1/office/settings/geographic`.

Refs Scaffald/SaaS#856

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay merged commit f29eb76 into main Sep 22, 2026
@thinkclay
thinkclay deleted the fix/856-office-settings branch September 22, 2026 19:38
thinkclay added a commit to Scaffald/SaaS that referenced this pull request Sep 22, 2026
thinkclay added a commit to Scaffald/SaaS that referenced this pull request Sep 22, 2026
…t PostgREST (#863)

* fix(office): the geographic settings screen reads through the API, not PostgREST

`core.system_config` has RLS off and grants nothing to `authenticated`, so
the screen's direct `supabase.schema('core')` read answered 42501 on every
load. The grant is deliberately not widened: the table holds platform
limits — storage caps, photo limits, the site-overlap threshold — that
only the office role may read or change, and SELECT for every logged-in
user is a far wider door than one admin form needs. Service role behind a
role-checked endpoint is how every other office screen reads privileged
data.

  GET  /v1/office/settings/geographic
  PUT  /v1/office/settings/geographic

A missing row is not an error: the setting has simply never been changed
from its default, and answering 404 would put the screen into its error
state on a healthy install. `value` is jsonb and has been written both as
a number and as a quoted string, so the handler reads either.

On the client, `useGeographicSettings` / `useUpdateGeographicSettings`
replace the direct query. The failed read now renders once, with a retry,
instead of raising a toast from inside the effect that fetched — which is
what made the failure re-trigger itself (#852 fixed the unbounded half;
this removes the failure).

Needs the pointer re-pointed at the squashed commit once Scaffald/sdk#31
merges.

Closes #856

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

* chore(sdk): repoint the submodule at the squashed commit on sdk main

Scaffald/sdk#31 merged as f29eb76.

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

---------

Co-authored-by: Claude Opus 5 <[email protected]>
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