AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Malformed Dollar Quoting In Realtime Trigger Examples

Three trigger function examples in examples/prompts/use-realtime.md have incorrectly placed AS $$, resulting in invalid SQL that cannot be executed.

mediumConfidence 92%Supabasepgvectorsupabase-jsRealtime

Origin Analysis

The examples place AS $$ immediately after RETURNS TRIGGER, then repeat AS $$ after function attributes, causing the attributes to be inside the dollar-quoted string and leaving an unbalanced delimiter.
Open examples/prompts/use-realtime.md at lines 167-237. Copy any of the three complete CREATE FUNCTION statements into a PostgreSQL session. Observe that the statements fail due to incorrect dollar-quote placement, as the function attributes are included inside the first quoted string and the final $$ lacks a matching opening delimiter.

Fixing Code Block

CREATE OR REPLACE FUNCTION notify_table_changes() RETURNS TRIGGER SECURITY DEFINER LANGUAGE plpgsql AS $$ BEGIN PERFORM realtime.broadcast_changes( TG_TABLE_NAME ||':' || COALESCE(NEW.id, OLD.id)::text, TG_OP, TG_OP, TG_TABLE_NAME, TG_TABLE_SCHEMA, NEW, OLD ); RETURN COALESCE(NEW, OLD); END; $$; -- Apply the same header correction to room_messages_broadcast_trigger() -- and notify_custom_event(): move AS $$ from after RETURNS TRIGGER -- to before BEGIN, leaving SECURITY DEFINER and LANGUAGE plpgsql outside the body.
Removes the premature AS $$ immediately after RETURNS TRIGGER and places the single AS $$ delimiter directly before BEGIN. This keeps function attributes like SECURITY DEFINER and LANGUAGE plpgsql outside the dollar-quoted body and balances the delimiters.

Edge Case Audit

This is a documentation-only fix; no runtime or version compatibility risks. Rollback is straightforward by restoring the previous malformed examples. Ensure that any external references or copied snippets are updated consistently.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state