https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Cannot run function locally, possibly due to deno version or std version.
    u

    uneatenauthor

    09/29/2022, 9:22 PM
    Before I get into this, I just want to say that I've found edge functions and deno generally to be very difficult to use. There has not been much documentation to cover common failure modes and much of the libraries (even the standard library itself!) is considered unstable per the deno site. The user experience has not aligned with the rest of supabase in my opinion. On to the main topic: I created a couple of edge functions about a month ago and got them working. Yesterday I decided I wanted to update on of them. So as I typically do, I updated my supabase cli, my deno runtime, and restarted all my local containers. Everything should be up to date now. I went to run the functions locally and sure enough, they are broken. You can find the output here: https://gist.github.com/point-source/a1831e9b109878df6c11aac718e62dd1 To improve search on here, the first line of output is:
    Argument of type '"CAA"' is not assignable to parameter of type 'RecordType'
    Googling this issue doesn't turn up much other than pointing to possible a version mismatch somewhere amongst the dependencies. I noticed that the error is looking at deno standard library 0.153.0 while the latest is 0.158.0. Since my local runtime is up-to-date, I can only assume that this is either coming from my function (which does not specify a std lib version) or from supabase docker stack or cli. How do I figure out what std library version is being used by supabase when I deploy a function locally? Where exactly is this function being run? How to I keep the supabase deno runtime and my local machine deno version in sync so that I can get correct analysis in vscode while I write these functions? How do I manage dependencies with deno? It seems like it wants me to do that by putting version numbers in the import urls but this would require me to upgrade them by searching for each one and updating the version by hand. This sounds awful. Why isn't there a package.lock or similar? I'm just so frustrated with supabase edge functions generally and it's such an unusual stack that it's hard to find help. For context, I've used azure and gcp functions for years now.
    u
    • 2
    • 3
  • Chain Supabase Insert(s)
    n

    Nin

    09/29/2022, 9:53 PM
    Wondering if I can chain a Supabase insert, for example: Insert into table x Select newly inserted row Insert into table y with id of newly inserted row And if so, how would a JS function look like?
    g
    • 2
    • 8
  • How Should I Estimate Usage?
    c

    czypnt

    09/29/2022, 9:58 PM
    First time building and launching a mobile app coded in react native. I optimized all my api calls as much as I can and its about 3-4 per screen (using cURLS as of now to access backend). I also have 1 auth token that is refreshed each time the User reloads a feed, so it can assign them a new JWT token. Now, on the launch side (I work in marketing), I am expecting quite a bit of users on launch around ~1k users. How much should I be estimating I will get in auth, storage and api calls? Even thought it is unlimited calls, what would be considered too much? Thank you
    g
    • 2
    • 1
  • Bulk delete test auth users vs. manually
    w

    wave_pt_CoL

    09/29/2022, 10:42 PM
    would anyone know how to? thanks in advance
    n
    • 2
    • 2
  • Cannot read properties of undefined (reading 'user') sveltekit auth-helpers
    r

    rgfx

    09/29/2022, 11:51 PM
    Using this repo https://github.com/supabase/auth-helpers/tree/main/examples/sveltekit-email-password
    Copy code
    Cannot read properties of undefined (reading 'user')
    TypeError: Cannot read properties of undefined (reading 'user')
        at +layout.svelte:39:27
        at Object.$$render (/node_modules/.pnpm/svelte@3.50.1/node_modules/svelte/internal/index.mjs:1771:22)
        at Object.default (root.svelte:43:39)
        at eval (/src/routes/+layout.svelte:22:41)
        at Object.$$render (/node_modules/.pnpm/svelte@3.50.1/node_modules/svelte/internal/index.mjs:1771:22)
        at root.svelte:41:37
        at $$render (/node_modules/.pnpm/svelte@3.50.1/node_modules/svelte/internal/index.mjs:1771:22)
        at Object.render (/node_modules/.pnpm/svelte@3.50.1/node_modules/svelte/internal/index.mjs:1779:26)
        at render_response (file:///C:/rgfx/auth/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.505_svelte@3.50.1+vite@3.1.4/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:122:27)
        at async render_page (file:///C:/rgfx/auth/node_modules/.pnpm/@svelt
    /src/routes/+layout.svelte is pertty simple.
    Copy code
    <script>
        // we need to make sure the supabase instance is initialized on the client
        import '$lib/db';
        import { startSupabaseSessionSync } from '@supabase/auth-helpers-sveltekit';
        import { invalidateAll } from '$app/navigation';
        import { page } from '$app/stores';
      
        // this sets up automatic token refreshing
        startSupabaseSessionSync({
          page,
          handleRefresh: () => invalidateAll()
        });
      </script>
      
      <slot />
    Anyone got any leads for me to look into.
    g
    • 2
    • 26
  • deleted
    n

    NanoBit

    09/30/2022, 3:12 AM
    What have you tried? The doc is a bit weird, but if you do not provide options, it’ll be just {}. I usually use typescript to see the actual Params needed
    • 1
    • 1
  • I signed up with email and when I try to sign up again with the same email, no error is thrown?
    v

    Vik

    09/30/2022, 2:02 AM
    As the title says, I'm on 2.0.0-rc.10 and if I try to sign up with an email that is already registered no error is returned. Is this a bug that I should report or are we expected to check for an existing auth user somehow first?
    g
    • 2
    • 2
  • Error On Insert Flutter
    r

    rlee128

    09/30/2022, 2:37 AM
    I keep receiving this error
    Copy code
    query has no destination for result data, code: 42601, details: Bad Request, hint: If you want to discard the results of a SELECT, use PERFORM instead.
    Each time a try to do an insert in flutter. This started after adding a trigger.
    n
    • 2
    • 14
  • Send email to admin periodically
    a

    AlanK

    09/30/2022, 4:07 AM
    I'm really out of my knowledge space on this one... I need to be able to email the results of a query to a specific email address every 24 hrs (say). I can set up the queries, functions & triggers I need. I have set up a SendGrid account and even enabled custom SMTP provider settings... but I realise that's not what I want. I'm hoping that someone can outline the simplest process (baby steps please) for sending an email from a database trigger?
    f
    • 2
    • 3
  • How to open Google OAuth In a Modal and not get a complete redirect?
    a

    anurag

    09/30/2022, 6:50 AM
    [Please see the screenshots you'll understand the question] Supabase Google OAuth does a redirect for signing in. The problem is if the user performing some operation such as saving something, it's difficult to redirect to that same state again. So my question is how do I open a modal for signing in and not a complete redirect? (Shown in the first screenshot)
    g
    n
    • 3
    • 4
  • My paused supabase instance does not restore, seems to infinitely stuck at 'restoration in progress'
    t

    thomas_mol

    09/30/2022, 7:57 AM
    Any ideas? My database was very small (no rows, just some table schemes and functions), and I've waited more than 12 hours now.
    g
    • 2
    • 1
  • get email from metadata with magic link
    t

    timmy

    09/30/2022, 8:24 AM
    I've done this before with google sign in, but I don't recall the function I used. Currently I am using a magic link with this function to trigger a new profile:
    Copy code
    sql
    
    begin
      insert into public.profiles (id, email)
      values (new.id, new.raw_user_meta_data->>'email');
      return new;
    end;
    that was just a shot in the dark, but is there some way to populate the "email" field in in "profiles" with the email address from "users" when a new profile is created via a trigger on auth? using magic link authentication
    g
    • 2
    • 1
  • how to use a POSTGIS function in a .select()
    g

    goldaeon

    09/30/2022, 8:54 AM
    Hi all ! I 've tried supabase for a new project and it looks great. I'm trying to do something like this : **await supabase .from("items") .select(
    Copy code
    id,
            title,
            body,
             ST_X(location),
             ST_Y(location)
    )** but it seems like it does not work. Is there a special way to do that or should I use RPC ? Thanks in advance for your help
    j
    g
    • 3
    • 2
  • Can't understand how to Construct a proper query
    u

    ((()))

    09/30/2022, 9:12 AM
    in SQL get exactly what I want
    Copy code
    sql
    select 
        munies.name as municipality,
        concat(muni_admins.first_name, muni_admins.last_name) as "admin",
        muni_offices.name as office,
        muni_users.user_id,
        muni_users.first_name,
        muni_users.middle_name,
        muni_users.last_name,
        muni_users.role,
        muni_users.email,
        muni_users.phone,
        muni_users."isActive" as status
    from munies
    join muni_admins on munies.muni_id = muni_admins.muni_id
    join muni_offices on munies.muni_id =  muni_offices.muni_id
    join muni_users on muni_offices.office_id = muni_users.office_id
    where muni_users.user_id = '0dea707d-2248-4a2e-b8fd-b65578852ca9'
    which gives me very nice clean table for data named exactly how I want and in proper order. Try to make supabase-js equalent
    Copy code
    js
    userDetails(userId) {
    return supabase
      .from('munies')
      .select(`
      name,
      muni_offices(name, muni_users(first_name, middle_name, last_name, role, email, phone, isActive)),
      muni_admins(first_name, last_name)
      `)
      .eq('muni_users.user_id', userId)
      .single();
    }
    j
    • 2
    • 8
  • Getting a permission denied error when trying to set parameter 'pgrst.db_pre_request'
    h

    Heath

    09/30/2022, 10:47 AM
    In our NextJS/supabase project I'm trying to configure postgREST with a
    db_pre_request
    function according to the documentation https://postgrest.org/en/stable/configuration.html#db-pre-request and also following this github issue https://github.com/supabase/supabase/issues/3233 It works fine when I spin up my environment locally using
    supabase start
    and
    supabase db reset
    . The parameter gets set and my function runs correctly. Unfortunately I get an error when I try to run the migrations for a linked supabase project. Here is the SQL in the migration that is failing
    Copy code
    postgres
    -- inside of migration 20220914185059...
    ALTER ROLE postgres SET pgrst.db_pre_request to db_pre_request;
    NOTIFY pgrst, 'reload config';
    Here is the command and error I'm seeing
    Copy code
    Run supabase link --project-ref $NEXT_PUBLIC_SUPABASE_ID --password SUPABASE_DB_PASSWORD
    Finished supabase link.
    Applying unapplied migrations...
    Error: ERROR: permission denied to set parameter "pgrst.db_pre_request" (SQLSTATE 42501); while executing migration 20220914185059
    Error: Process completed with exit code 1.
    Can anyone help? My first thought is that whatever role is being used to run the migrations doesn't have the right GRANTs, but I don't know how to check that. Any other ideas, or solutions?
    n
    • 2
    • 5
  • Where clause on join not working, shouldn't return rows but still does
    k

    Kcrik

    09/30/2022, 10:54 AM
    Hello guys, I have 2 tables with a join to link them together. typically Table 1 id name table_2_id Table 2 id name type In sql, if I wanted to return the row from table 1, where the type in table 2 is specific, I would just do: select * from table1 join table2 on table2.id = table1.table_2_id where table2.type = 'form_supa' I expect it to return nothing as the type is set as something else. In pure SQL,it works exactly as expected. With supabase client, I tried ton use the .match("table2.type", 'form_supa')...but all it does is just not return the matches between table 1 and table 2...but still return the table1 entries. How do you enforce the WHERE on join and inner join with the supabase client ? Thanks in advance for the help
    j
    g
    • 3
    • 10
  • Insert 3 rows at once
    r

    rlee128

    09/30/2022, 1:20 PM
    How to insert 3 rows at once via a trigger using the values 3 times does not work
    Copy code
    begin
      insert into public.reactioncount(parent_id, reaction_value)
      values(new.id, 'share');
      values(new.id, 'comment');
      values(new.id, 'like');
      return new;
    end;
    j
    n
    • 3
    • 4
  • User stays logged in after logout in local dev enviroment
    ł

    ŁukaszW.

    09/30/2022, 4:04 PM
    After log out , my app is still sending user token within the client. It happens only on local machine, the same app works normally on managed server. Supabase client is created in API endpoint by "auth-helpers/next"
    Copy code
    supabaseServerClient({ req: opts.req })
    After log out still having user on it, event if the cookies and all sesions are cleared
    g
    • 2
    • 1
  • Insert filter to void duplicates?
    m

    mr madcat

    09/30/2022, 6:27 PM
    Is there a way to filter tables before inserting a new entry to check for already existing values to avoid duplication?
    • 1
    • 1
  • Autofill UID in the referenced column.
    j

    jdgamble555

    09/30/2022, 9:25 PM
    there is a uuid function. Edit the table, and click the default value, and that function will appear
    h
    g
    • 3
    • 15
  • Sveltekit auth helpers URLSearchParams empty
    r

    rgfx

    09/30/2022, 7:00 PM
    Is URLSearchParams supposed to be empty What might I be doing wrong, how does URLSearchParams get populated?
  • where do i set the count=estimated threshold in flutter supabase?
    o

    oski啦

    09/30/2022, 8:09 PM
    i read in the docs that count=estimated can be set to a threshold but am not sure where you would do this in the flutter library. is there a way to do it? or has the threshold been predetermined? thanks!
    g
    • 2
    • 2
  • Do trigger functions work locally?
    c

    corasan

    09/30/2022, 8:35 PM
    I am trying to work on my local environment but I can't because none of my triggers work locally. I see that they are in the migration file, but they never run. For example I have a trigger to create a user profile when a user is created, which works fine in Supabase Studio, but not locally.
    h
    • 2
    • 2
  • http_get
    d

    dave johnson

    09/30/2022, 9:36 PM
    this might be a not great question... = Is there a way to add headers/authentication to the HTTP get function? is there syntax that can work similar to kanye api example? select "content"::jsonb from http_get('https://api.nettoolkit.com/v1/geo/names?text=duan&latitude=37.399848&longitude=-121.898101&distance=5' , http_header('-h X-NTK-KEY: test_4apTtDZbcC3bp3dZcwnsZBTaoKbUxFQ6BheRIIXg'))
    g
    • 2
    • 5
  • Script out storage buckets
    m

    martypdx

    09/30/2022, 10:27 PM
    I'm trying to create SQL Scripts for setting up storage buckets. I can get the policies from the storage.objects table so that seems good. But do buckets need to be created thru the UI in order to have them provisioned on S3? Or can that be done in SQL Script manner, meaning can I simply insert a row into storage.buckets?
    g
    • 2
    • 7
  • storage egress limit exceeded meaning
    g

    gerry

    09/30/2022, 10:47 PM
    Trying to understand what goes into calculating storage egress. Does every time my website is visited and images are downloaded increase storage egress? What happens when the limit is exceeded?
    g
    • 2
    • 1
  • Has anyone used Supabase database with a different Auth provider? How did you manage security rules?
    v

    Vik

    10/01/2022, 12:16 AM
    Hey, so I’m using Firebase Auth in an existing application and it’s working wonders. I also plan on integrating other Firebase tools. Right now Firestore is looking like it won’t meet my needs so I want to use a relational database. Supabase is what I’m looking at now but I’m curious how rules would be managed if I can’t match user IDs. Has anyone gone down this road before and can give me some tips? Thanks!
    j
    g
    • 3
    • 19
  • Preventing psql function execution
    u

    uneatenauthor

    10/01/2022, 12:33 AM
    I have a utility function to check claims in RLS policies. It seems to be working well but I want to make sure that a user cannot call the function via the api in order to try to learn which users have which levels of access in the event that a malicious actor gains access to another user's uid. How can I restrict the function to use only by the RLS policy?
    j
    m
    g
    • 4
    • 3
  • Can I use the Twitter auth to connect my user's Twitter account
    z

    zander

    10/01/2022, 12:55 AM
    I want my users to be able to connect their Twitter account with my app so that they can see or interact with tweets. Is it possible to use the "Login with Twitter" flow to connect with Twitter and access tweet info? Does that make sense? Or do I have to build the connection myself?
    j
    s
    • 3
    • 4
  • cannot return non-composite value from function returning composite type
    r

    rlee128

    10/01/2022, 4:08 AM
    I keep receiving this error cannot return non-composite value from function returning composite type the trigger function is below. I ran the insert without the trigger and it works.
    Copy code
    declare
      new_count bigint;
    begin
      
      select reaction_count into new_count from public.reactioncount
      where parent_id = new.parent_id and 
      reaction_value = new.reaction_type;
      new_count = new_count + 1;
    
      update public.reactioncount 
      set reaction_count = new_count
      where parent_id = new.parent_id and 
      reaction_value = new.reaction_type;
      return new, new_count;
    end;
    g
    • 2
    • 3
1...353637...230Latest