[{"data":1,"prerenderedAt":353},["ShallowReactive",2],{"blog-en-2026-03-01-tokyo-service-supabase":3},{"id":4,"title":5,"body":6,"category":334,"date":335,"description":336,"draft":337,"extension":338,"lang":339,"meta":340,"navigation":346,"path":347,"seo":348,"sitemap":349,"slug":350,"stem":351,"updated":335,"__hash__":352},"blog/blog/en/2026-03-01-tokyo-service-supabase.md","Supabase Signup Failed: gen_random_bytes() does not exist",{"type":7,"value":8,"toc":320},"minimark",[9,14,18,29,32,42,46,52,56,63,69,72,75,78,82,88,99,102,106,111,166,170,215,219,228,231,237,241,244,255,258,266,270,273,276,287,295,299,302,316],[10,11,13],"h2",{"id":12},"problem","❗ Problem",[15,16,17],"p",{},"User signup fails with the following error:",[19,20,26],"pre",{"className":21,"code":23,"language":24,"meta":25},[22],"language-text","function gen_random_bytes(integer) does not exist\nNo function matches the given name and argument types\ncurrent transaction is aborted, commands ignored until end of transaction block\n","text","",[27,28,23],"code",{"__ignoreMap":25},[15,30,31],{},"Symptoms:",[33,34,35,39],"ul",{},[36,37,38],"li",{},"New users cannot be created",[36,40,41],{},"Supabase Auth signup continuously fails",[10,43,45],{"id":44},"execution-flow","🔄 Execution Flow",[19,47,50],{"className":48,"code":49,"language":24,"meta":25},[22],"Client Signup\n  ↓\nauth.users INSERT\n  ↓\nAFTER INSERT Trigger\n  ↓\ncreate_profile_for_new_user()\n  ↓\ngen_random_bytes()\n",[27,51,49],{"__ignoreMap":25},[10,53,55],{"id":54},"analysis","🔍 Analysis",[15,57,58,59,62],{},"gen_random_bytes() is not a PostgreSQL core built-in function.\nIt is provided by the pgcrypto extension.",[60,61],"br",{},"\nIn Supabase environments, pgcrypto functions are typically installed\nunder the extensions schema: extensions.gen_random_bytes().",[15,64,65,66,68],{},"During signup, Supabase executes:\nauth.users → trigger → custom function",[60,67],{},"\nThis trigger function commonly runs with SECURITY DEFINER.",[15,70,71],{},"A SECURITY DEFINER function does not inherit the caller's\nsearch_path. PostgreSQL instead uses the search_path recorded at the\ntime the function was created.",[15,73,74],{},"If this stored search_path does not include the extensions schema,\nPostgreSQL cannot resolve gen_random_bytes() even when pgcrypto is\ninstalled.",[15,76,77],{},"The failure occurs during function lookup, not during extension installation.",[10,79,81],{"id":80},"root-cause","🎯 Root Cause",[15,83,84,85,87],{},"Supabase Auth triggers typically execute using SECURITY DEFINER.",[60,86],{},"\nIn this mode:",[33,89,90,93,96],{},[36,91,92],{},"The function uses the search_path recorded at creation time",[36,94,95],{},"Non-default schemas (such as extensions) become invisible",[36,97,98],{},"Functions without explicit schema references fail to resolve",[15,100,101],{},"Therefore, the issue is not caused by Supabase Auth, but by schema\nvisibility inside a SECURITY DEFINER execution environment.",[10,103,105],{"id":104},"solutions","✅ Solutions",[107,108,110],"h3",{"id":109},"explicit-schema-reference","Explicit schema reference",[19,112,116],{"className":113,"code":114,"language":115,"meta":25,"style":25},"language-sql shiki shiki-themes github-light github-light github-dark","extensions.gen_random_bytes(16)\n-- or\npgcrypto.gen_random_bytes(16)\n","sql",[27,117,118,143,150],{"__ignoreMap":25},[119,120,123,127,131,134,137,140],"span",{"class":121,"line":122},"line",1,[119,124,126],{"class":125},"sBjJW","extensions",[119,128,130],{"class":129},"sxrX7",".",[119,132,133],{"class":125},"gen_random_bytes",[119,135,136],{"class":129},"(",[119,138,139],{"class":125},"16",[119,141,142],{"class":129},")\n",[119,144,146],{"class":121,"line":145},2,[119,147,149],{"class":148},"sCsY4","-- or\n",[119,151,153,156,158,160,162,164],{"class":121,"line":152},3,[119,154,155],{"class":125},"pgcrypto",[119,157,130],{"class":129},[119,159,133],{"class":125},[119,161,136],{"class":129},[119,163,139],{"class":125},[119,165,142],{"class":129},[107,167,169],{"id":168},"set-search_path-inside-the-function","Set search_path inside the function",[19,171,173],{"className":113,"code":172,"language":115,"meta":25,"style":25},"CREATE OR REPLACE FUNCTION ...\nSECURITY DEFINER\nSET search_path = public, extensions;\n",[27,174,175,193,201],{"__ignoreMap":25},[119,176,177,181,184,187,190],{"class":121,"line":122},[119,178,180],{"class":179},"s8jYJ","CREATE",[119,182,183],{"class":179}," OR",[119,185,186],{"class":179}," REPLACE",[119,188,189],{"class":179}," FUNCTION",[119,191,192],{"class":129}," ...\n",[119,194,195,198],{"class":121,"line":145},[119,196,197],{"class":179},"SECURITY",[119,199,200],{"class":129}," DEFINER\n",[119,202,203,206,209,212],{"class":121,"line":152},[119,204,205],{"class":179},"SET",[119,207,208],{"class":129}," search_path ",[119,210,211],{"class":179},"=",[119,213,214],{"class":129}," public, extensions;\n",[107,216,218],{"id":217},"alternative-random","Alternative: random()",[19,220,222],{"className":113,"code":221,"language":115,"meta":25,"style":25},"random()\n",[27,223,224],{"__ignoreMap":25},[119,225,226],{"class":121,"line":122},[119,227,221],{"class":129},[15,229,230],{},"⚠️ Warning:",[15,232,233,236],{},[27,234,235],{},"random()"," is not cryptographically secure and should NOT be used for\ntokens, handles, or security-sensitive identifiers.",[10,238,240],{"id":239},"️-best-practices","🛡️ Best Practices",[15,242,243],{},"For Auth triggers, avoid:",[33,245,246,249,252],{},[36,247,248],{},"Extension-dependent logic",[36,250,251],{},"Cross-schema calls",[36,253,254],{},"Complex business logic",[15,256,257],{},"Triggers should only handle:",[33,259,260,263],{},[36,261,262],{},"Basic INSERT operations",[36,264,265],{},"Minimal data initialization",[10,267,269],{"id":268},"summary","📌 Summary",[15,271,272],{},"The gen_random_bytes() error does not mean the function is missing.",[15,274,275],{},"Instead:",[33,277,278,281,284],{},[36,279,280],{},"SECURITY DEFINER changes schema visibility",[36,282,283],{},"search_path excludes the extensions schema",[36,285,286],{},"pgcrypto functions cannot be resolved",[15,288,289,290,294],{},"This is fundamentally a ",[291,292,293],"strong",{},"PostgreSQL schema visibility issue",",\nnot a Supabase bug or extension installation problem.",[10,296,298],{"id":297},"applicable-scenarios","📎 Applicable Scenarios",[15,300,301],{},"This article applies to:",[33,303,304,307,310,313],{},[36,305,306],{},"Supabase Auth trigger failures",[36,308,309],{},"PostgreSQL SECURITY DEFINER issues",[36,311,312],{},"pgcrypto function resolution errors",[36,314,315],{},"Extension functions failing inside triggers",[317,318,319],"style",{},"html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}",{"title":25,"searchDepth":145,"depth":145,"links":321},[322,323,324,325,326,331,332,333],{"id":12,"depth":145,"text":13},{"id":44,"depth":145,"text":45},{"id":54,"depth":145,"text":55},{"id":80,"depth":145,"text":81},{"id":104,"depth":145,"text":105,"children":327},[328,329,330],{"id":109,"depth":152,"text":110},{"id":168,"depth":152,"text":169},{"id":217,"depth":152,"text":218},{"id":239,"depth":145,"text":240},{"id":268,"depth":145,"text":269},{"id":297,"depth":145,"text":298},"supabase","2026-03-01T00:00:00.000Z","The real cause of the Supabase Signup error\n\"gen_random_bytes() does not exist\":\n PostgreSQL SECURITY DEFINER uses\na fixed search_path, making pgcrypto functions inaccessible.",false,"md","en",{"tags":341},[334,342,343,155,344,345],"postgresql","trigger","security-definer","database-debug",true,"/blog/en/2026-03-01-tokyo-service-supabase",{"title":5,"description":336},{"loc":347},null,"blog/en/2026-03-01-tokyo-service-supabase","c_p64c67qJSyLJ25pFVhrhvF2gDAq_gjWb0a-0jvzf8",1784966030600]