Skip to main content

Current source boundary

This page covers the historical Supabase apply_hive_world_event() path. Current checked-in Hive event handlers call createHiveWorldEvent() against HIVE_DATABASE_URL inside the satellite. Confirm deployed source and database authority before applying a legacy-function fix; see the Hive data model and Cloudflare migration plan.

Symptoms

When creating a Hive world event, the API can return:
This surfaces as hive_event_failed in the client with a 400 error.

Cause

apply_hive_world_event returns a table signature that includes server_id. In PL/pgSQL, output columns are variables. Unqualified references to server_id inside the function can become ambiguous and fail at runtime.

Fix

Use a constraint-based conflict target in the insert that bootstraps hive_world_states so the SQL does not rely on a bare server_id identifier:
Apply the migration and re-run Hive event creation after the updated function is live.

Actor Authorization

The actor-accepting apply_hive_world_event(uuid, uuid, bigint, text, jsonb, jsonb) overload should not be exposed to browser roles. Keep direct execution revoked from public, anon, and authenticated; legacy server-side API and realtime paths call it with service_role after validating the user session or signed Hive realtime token. If a non-service role ever reaches the function, it must derive the actor from auth.uid() and reject mismatched p_actor_user_id values with hive_actor_mismatch.