Supabase pgvector triggers Function Search Path Mutable security warning
Shows how to fix supabase pgvector triggers Function Search Path Mutable security warning. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Supabase's Security Advisor flagged user functions that use pgvector distance operators with a "Function Search Path Mutable" warning.
Steps
- Supabase's Security Advisor flagged user functions that use pgvector distance operators with a "Function Search Path Mutable" warning. Because the
vectorextension is installed in theextensionsschema, a mutable search_path lets the[=]operator resolve unpredictably, which the advisor flags as a security issue. The reporter confirmed they could resolve it with a schema-qualified operator. - Pin the operator to its schema: replace
[=]withOPERATOR(extensions.[=])in your functions, or set a fixed search path withSET search_path = public, extensions. Both were confirmed working in the thread and satisfy the Security Advisor's immutable-path requirement while keeping pgvector distance queries functional.
When to use
You are seeing this: Both were confirmed working in the thread and satisfy the Security Advisor's immutable-path requirement while keeping pgvector distance queries functional. Use this skill when you run into "Supabase pgvector triggers Function Search Path Mutable security warning".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
Because the vector extension is installed in the extensions schema, a mutable search_path lets the [=] operator resolve unpredictably, which the advisor flags