supabase / walrus

Applying RLS to PostgreSQL WAL
Apache License 2.0
122 stars 9 forks source link

Request: Error states return jsonb object with type (INSERT/UPDATE/DELETE) #33

Closed w3b6x9 closed 2 years ago

w3b6x9 commented 2 years ago

Summary

Clients are listening to specific event types (i.e. INSERT/UPDATE/DELETE) but when there's a Error 400: Bad Request, no primary key or 401: Unauthorized the payload is:

(
    null,                            -- wal
    true,                            -- is_rls_enabled
    [...],                           -- subscription_ids,
    array['Error 400: Bad Request, no primary key'] -- errors
)::realtime.wal_rls;

Realtime has no way of knowing what type of database change it was so there's no way to properly broadcast to clients.

Request

Return payload:

(
    {"type": "INSERT"},        -- wal
    true,                            -- is_rls_enabled
    [...],                           -- subscription_ids,
    array['Error 400: Bad Request, no primary key'] -- errors
)::realtime.wal_rls;