Skip to content

fix(api): GET /v1/profiles/general swallows DB errors and returns an empty profile with 200 #588

Closed

Description

@thinkclay

Both halves of /v1/profiles/general discard the Postgres error and return a success-shaped body, so a permissions failure or missing row is indistinguishable from "this user has an empty profile".

Evidence

packages/supabase/functions/api/routes/profiles.ts:366

const { data: profile } = await supabase.schema("core").from("users")
  .select("avatar_path, about").eq("id", user.id).single()
const { data: privateData } = await supabase.schema("core").from("profile")
  .select("first_name, last_name, address, phone").eq("user_id", user.id).single()

return c.json({
  first_name: privateData?.first_name ?? "",
  last_name:  privateData?.last_name  ?? "",
  …
}, 200)

error is never destructured. A grant gap (the class of bug in #481) or an RLS denial returns 200 with every field blank. The client then renders an editable empty form — and #580 turns that into a write of blanks.

Acceptance

  • Both queries check error and return 500 with the message.
  • .single() is replaced with .maybeSingle() so "no row yet" is a legitimate empty result, distinct from a failure.
  • A test asserts a forced DB error yields 5xx, not a 200 with empty strings.

Activity

  1. added
    bug
    agent-ready
    on Aug 12, 2026
  2. thinkclay commented on Aug 12, 2026

    @thinkclay
    ContributorAuthor

    Part of the profile-building audit rollup: #594

  3. thinkclay commented on Aug 12, 2026

    @thinkclay
    ContributorAuthor

    Fixed in #597 — both queries now check error and return 5xx, and .single() became .maybeSingle() so "no row yet" stays a legitimate empty result rather than an error. This was the input that made #580 destructive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backendagent-readybugpriority: hightype: backend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions