Skip to content

BUG: PATCH writes via /api/v1/settings, /admin/themes, /admin/customizer 500 — non-existent namespace column #524

@tayebmokni

Description

@tayebmokni

Summary

Surfaced during work on #499. Three packages share the same write-side
bug — `upsertSQL` writes to a `namespace` column that does not exist
in the `options` table (migration 000008).

Affected files

  • `packages/go/settings/postgres.go` — `upsertSQL` and its single caller in `Set`/`SetMany`
  • `packages/go/themes/store.go` — same pattern when persisting `active_theme`
  • `packages/go/customizer/store.go` — same pattern when persisting overrides

GET path is unaffected; all three select against `key`/`value` only.

Reproduction

  1. Boot the stack (`docker compose up -d`).
  2. Sign in as admin.
  3. Open admin → Settings → General. Change the site name. Save.

Expected: 200, page reloads with new value.
Actual: 500 from `/api/v1/settings` (`column "namespace" does not exist`).

Same reproduces on:

  • Appearance → Customize → Save (saves overrides)
  • Appearance → Themes → switch active theme

Recommended fix

Either:

(a) Add a `namespace` column to the `options` table via a new migration. Default to `''` for existing rows. Update the GET path's WHERE clauses to filter by namespace too. Riskier — broadens the schema.

(b) Strip the `namespace` column from the three `upsertSQL` statements. The current code never populates it from anything but a hardcoded constant. Cheapest fix; matches the schema as it ships.

Recommend (b) for now. Re-evaluate when multi-tenant work lands.

Acceptance

  • Each Settings sub-page "Save" button persists and reloads with the saved value.
  • `go test ./packages/go/settings/...` covers a Set→Get round-trip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apiGo HTTP API serverphase:P1-cms-corePhase 1 — CMS Corepriority:P1Important — should land in phaseskill:goGo programmingtype:bugDefect in shipped code

    Type

    No type
    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