© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•5mo ago•
5 replies
PeanutBuddha

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" }
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$
;
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$
;
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Auth trigger didn't run locally
SupabaseSSupabase / help-and-questions
10mo ago
Can't use auth.uid() inside functions
SupabaseSSupabase / help-and-questions
4y ago
Do trigger functions work locally?
SupabaseSSupabase / help-and-questions
4y ago
Cna't turn on vault!
SupabaseSSupabase / help-and-questions
13mo ago