Can't use vault inside trigger locally

I'm using Docker on Windows WSL2

I'm using the Supabase JS SDK to call a function which reads from the vault:

Object { code: "22000", details: null, hint: null, message: "pgsodium_crypto_aead_det_decrypt_by_id: invalid ciphertext" }


When I call it from my SQL client (DBeaver) it works properly. Other function calls and SQL queries work correctly.

My simple func:

CREATE OR REPLACE FUNCTION public.get_api_url()
 RETURNS text
 LANGUAGE plpgsql
 SECURITY DEFINER
 SET search_path TO 'public', 'vault', 'pg_temp'
AS $function$
DECLARE
    api_url TEXT;
BEGIN
    SELECT decrypted_secret
    INTO api_url
    FROM vault.decrypted_secrets
    WHERE name = 'api_url'
    LIMIT 1;

    RETURN api_url;
END;
$function$
;
Was this page helpful?