supabase: Twilio Verify does not work on local development
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
SMS/WhatsApp auth methods (like auth.signInWithOtp) throw a generic error message when using Twilio Verify in local development. The same config (same keys, same methods) work as intended in Supabase Cloud.
config.toml
[auth.sms.twilio_verify]
enabled = true
account_sid = "env(TWILIO_ACCOUNT_SID)"
message_service_sid = "env(TWILIO_VERIFY_MESSAGE_SERVICE_SID)"
auth_token = "env(TWILIO_AUTH_TOKEN)"
test.js
import 'dotenv/config';
import { createClient } from '@supabase/supabase-js';
const SUPABASE_URL = process.env.SUPABASE_URL;
const SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY;
const PHONE_NUMBER = process.env.PHONE_NUMBER;
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
const { data, error } = await supabase.auth.signInWithOtp({
phone: PHONE_NUMBER,
options: {
channel: 'whatsapp' // or 'sms'
}
});
console.log('data');
console.log(data);
console.log('error');
console.log(error);
node log
data
{ user: null, session: null }
error
AuthRetryableFetchError: {}
at handleError (/home/ubuntu/projects/supabase-twilio-verify/node_modules/.pnpm/@supabase+gotrue-js@2.60.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:25:15)
at _handleRequest (/home/ubuntu/projects/supabase-twilio-verify/node_modules/.pnpm/@supabase+gotrue-js@2.60.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:81:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _request (/home/ubuntu/projects/supabase-twilio-verify/node_modules/.pnpm/@supabase+gotrue-js@2.60.1/node_modules/@supabase/gotrue-js/dist/main/lib/fetch.js:65:18)
at async SupabaseAuthClient.signInWithOtp (/home/ubuntu/projects/supabase-twilio-verify/node_modules/.pnpm/@supabase+gotrue-js@2.60.1/node_modules/@supabase/gotrue-js/dist/main/GoTrueClient.js:474:41)
at async file:///home/ubuntu/projects/supabase-twilio-verify/test.js:11:25 {
__isAuthError: true,
status: 502
}
docker auth container log
2023-12-16 20:58:20 {"component":"api","level":"info","method":"POST","msg":"request started","path":"/otp","referer":"http://127.0.0.1:3000","remote_addr":"172.22.0.1","time":"2023-12-16T23:58:20Z","timestamp":"2023-12-16T23:58:20Z"}
2023-12-16 20:58:20 {"auth_event":{"action":"user_recovery_requested","actor_id":"fb6916cc-f647-48a6-af0a-bf56f1de91e7","actor_username":"[REDACTED]","actor_via_sso":false,"log_type":"user","traits":{"channel":"whatsapp"}},"component":"api","duration":107271912,"level":"info","method":"POST","msg":"request completed","path":"/otp","referer":"http://127.0.0.1:3000","remote_addr":"172.22.0.1","status":0,"time":"2023-12-16T23:58:20Z","timestamp":"2023-12-16T23:58:20Z"}
2023-12-16 20:58:20 2023/12/16 23:58:20 http: panic serving 172.22.0.3:38628: runtime error: invalid memory address or nil pointer dereference
2023-12-16 20:58:20 goroutine 322 [running]:
2023-12-16 20:58:20 net/http.(*conn).serve.func1()
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:1868 +0xb9
2023-12-16 20:58:20 panic({0xf0c980?, 0x192ab30?})
2023-12-16 20:58:20 /usr/local/go/src/runtime/panic.go:920 +0x270
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/storage.(*Connection).Transaction.(*Connection).Transaction.func2.1()
2023-12-16 20:58:20 /go/pkg/mod/github.com/gobuffalo/pop/v6@v6.1.1/connection.go:173 +0xb8
2023-12-16 20:58:20 panic({0xf0c980?, 0x192ab30?})
2023-12-16 20:58:20 /usr/local/go/src/runtime/panic.go:914 +0x21f
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api/sms_provider.(*TwilioVerifyProvider).SendSms(0xc00057e2a0, {0xc0002d5b21?, 0x15?}, {0xf29840?, 0xc000680680?}, {0xc0002d5aa8, 0x8})
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/sms_provider/twilio_verify.go:81 +0x403
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api/sms_provider.(*TwilioVerifyProvider).SendMessage(0xc000498d88?, {0xc0002d5b21?, 0x6?}, {0xc0000461b0?, 0xea69c0?}, {0xc0002d5aa8?, 0xf649a0?}, {0x1?, 0xc000498e20?})
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/sms_provider/twilio_verify.go:59 +0x5a
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.(*API).sendPhoneConfirmation(0x0?, {0x0?, 0x0?}, 0x0?, 0xc00047c3c0, {0xc0002d5b21, 0xd}, {0x106d109, 0xc}, {0x11f3f40, ...}, ...)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/phone.go:96 +0x5b2
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.(*API).SmsOtp.func1(0x1200c20?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/otp.go:206 +0x2c5
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/storage.(*Connection).Transaction.func1(0xc000700120)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/storage/dial.go:138 +0x5f
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/storage.(*Connection).Transaction.(*Connection).Transaction.func2()
2023-12-16 20:58:20 /go/pkg/mod/github.com/gobuffalo/pop/v6@v6.1.1/connection.go:177 +0xeb
2023-12-16 20:58:20 github.com/gobuffalo/pop/v6.commonDialect.Lock(...)
2023-12-16 20:58:20 /go/pkg/mod/github.com/gobuffalo/pop/v6@v6.1.1/dialect_common.go:29
2023-12-16 20:58:20 github.com/gobuffalo/pop/v6.(*Connection).Transaction(...)
2023-12-16 20:58:20 /go/pkg/mod/github.com/gobuffalo/pop/v6@v6.1.1/connection.go:157
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/storage.(*Connection).Transaction(0xc0001307c8, 0xc00040f720)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/storage/dial.go:137 +0x102
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.(*API).SmsOtp(0xc000404540, {0x7fb6e33bbb28, 0xc000264ac0}, 0xc000376a00)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/otp.go:196 +0xc1b
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.(*API).Otp(0xc000317a40?, {0x7fb6e33bbb28, 0xc000264ac0}, 0xc0002551a0?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/otp.go:96 +0x1d8
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.apiHandler.serve(0x100?, {0x7fb6e33bbb28, 0xc000264ac0}, 0x0?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:65 +0x2e
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0x7fb6e33bbb28?, {0x7fb6e33bbb28?, 0xc000264ac0?}, 0xc0002552c0?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.serve(0x7fb6e386a030?, {0x11f3fc0, 0xc0004b8760}, {0x7fb6e33bbb28, 0xc000264ac0}, 0xc000376900)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:87 +0x12b
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.handler-fm.middlewareHandler.handler.func1({0x7fb6e33bbb28?, 0xc000264ac0?}, 0x453901?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:74 +0x3b
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0x1?, {0x7fb6e33bbb28?, 0xc000264ac0?}, 0x2?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.serve(0xc0002553d0?, {0x11f3fc0, 0xc00040a5c0}, {0x7fb6e33bbb28, 0xc000264ac0}, 0xc000376800)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:87 +0x12b
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.handler-fm.middlewareHandler.handler.func1({0x7fb6e33bbb28?, 0xc000264ac0?}, 0x1?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:74 +0x3b
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0xc000317a40?, {0x7fb6e33bbb28?, 0xc000264ac0?}, 0xc0004ac2b0?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/go-chi/chi.(*ChainHandler).ServeHTTP(0xefeda0?, {0x7fb6e33bbb28?, 0xc000264ac0?}, 0xc0002d57c4?)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/chain.go:31 +0x26
2023-12-16 20:58:20 github.com/go-chi/chi.(*Mux).routeHTTP(0xc00026c120, {0x7fb6e33bbb28, 0xc000264ac0}, 0xc000376800)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/mux.go:425 +0x1f4
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0x7fb6e33bbb28?, {0x7fb6e33bbb28?, 0xc000264ac0?}, 0xc000376700?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.serve(0xc000255530?, {0x11f3fc0, 0xc0004b8410}, {0x7fb6e33bbb28, 0xc000264ac0}, 0xc000376700)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:87 +0x12b
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.handler-fm.middlewareHandler.handler.func1({0x7fb6e33bbb28?, 0xc000264ac0?}, 0xc000601800?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:74 +0x3b
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0xc000376600?, {0x7fb6e33bbb28?, 0xc000264ac0?}, 0x0?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.NewAPIWithVersion.NewStructuredLogger.RequestLogger.func9.1({0x11fcc08, 0xc000310380}, 0xc000376600)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/middleware/logger.go:46 +0x16d
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0xc000255670?, {0x11fcc08?, 0xc000310380?}, 0xc000255650?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/go-chi/chi.(*Mux).ServeHTTP(0xc00026c120, {0x11fcc08, 0xc000310380}, 0xc000376600)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/mux.go:70 +0x2f3
2023-12-16 20:58:20 github.com/go-chi/chi.(*Mux).Mount.func1({0x11fcc08, 0xc000310380}, 0xc000376600)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/mux.go:292 +0x167
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0xefeda0?, {0x11fcc08?, 0xc000310380?}, 0xc00014f1a5?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/go-chi/chi.(*Mux).routeHTTP(0xc00026c060, {0x11fcc08, 0xc000310380}, 0xc000376600)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/mux.go:425 +0x1f4
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0x11fcc08?, {0x11fcc08?, 0xc000310380?}, 0xc0004ac1e0?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.serve(0xeda660?, {0x11f3fc0, 0xc0004b82b0}, {0x11fcc08, 0xc000310380}, 0xc000376600)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:87 +0x12b
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.handler-fm.middlewareHandler.handler.func1({0x11fcc08?, 0xc000310380?}, 0xc0002d55cb?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:74 +0x3b
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0xc000376600?, {0x11fcc08?, 0xc000310380?}, 0x7fb72a3c4108?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/sebest/xff.(*XFF).Handler-fm.(*XFF).Handler.func1({0x11fcc08, 0xc000310380}, 0xc000376600)
2023-12-16 20:58:20 /go/pkg/mod/github.com/sebest/xff@v0.0.0-20160910043805-6c115e0ffa35/xff.go:128 +0xa4
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0xfd28e0?, {0x11fcc08?, 0xc000310380?}, 0xc000224950?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.serve(0x7fb6e386a030?, {0x11f3fc0, 0xc00040a140}, {0x11fcc08, 0xc000310380}, 0xc000376500)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:87 +0x12b
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.middlewareHandler.handler-fm.middlewareHandler.handler.func1({0x11fcc08?, 0xc000310380?}, 0x192b901?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:74 +0x3b
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0x1200c20?, {0x11fcc08?, 0xc000310380?}, 0x192b960?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/go-chi/chi.(*Mux).ServeHTTP(0xc00026c060, {0x11fcc08, 0xc000310380}, 0xc000376400)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/mux.go:82 +0x2b1
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.(*router).ServeHTTP(0xc000376300?, {0x11fcc08?, 0xc000310380?}, 0x192b800?)
2023-12-16 20:58:20 /go/src/github.com/supabase/gotrue/internal/api/router.go:55 +0x28
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.NewAPIWithVersion.ServerBaseContext.func7({0x11fcc08, 0xc000310380}, 0xc0002f7d68?)
2023-12-16 20:58:20 /go/pkg/mod/github.com/go-chi/chi@v4.0.2+incompatible/context.go:147 +0x159
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0xc000176480?, {0x11fcc08?, 0xc000310380?}, 0xc000376300?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 github.com/supabase/gotrue/internal/api.NewAPIWithVersion.(*Cors).Handler.func8({0x11fcc08, 0xc000310380}, 0xc000376300)
2023-12-16 20:58:20 /go/pkg/mod/github.com/rs/cors@v1.9.0/cors.go:236 +0x184
2023-12-16 20:58:20 net/http.HandlerFunc.ServeHTTP(0x410905?, {0x11fcc08?, 0xc000310380?}, 0xc000310301?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2136 +0x29
2023-12-16 20:58:20 net/http.serverHandler.ServeHTTP({0x11f9b60?}, {0x11fcc08?, 0xc000310380?}, 0x6?)
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2938 +0x8e
2023-12-16 20:58:20 net/http.(*conn).serve(0xc000262e10, {0x1200c20, 0xc0003cc840})
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:2009 +0x5f4
2023-12-16 20:58:20 created by net/http.(*Server).Serve in goroutine 1
2023-12-16 20:58:20 /usr/local/go/src/net/http/server.go:3086 +0x5cb
To Reproduce
Minimal repro: github.com/luisfontes/supabase-twilio-verify
- add the env vars
- supabase init & supabase start
- run
node test.js
Expected behavior
The minimal repro above works if I point it to my supabase cloud instance. I expect Twilio Verify to work as intended in local development.
node log
data
{
user: null,
session: null,
messageId: 'VEda315a02c84906b4e7676ee0d44ae70d'
}
error
null
System information
- OS: Windows on WSL2
- Version of supabase-js: ^2.39.0
- Version of supabase: ^1.123.4
- Version of Node.js: 20.10.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (7 by maintainers)
Hey team,
I’m going to close this for now but feel free to re-open if the issue persists after the next release. There should be an error message that shows up after his release so it will probably be easier to debug thereafter.
Once again, thanks everyone for staying with us, replicating the issue and supplying feedback. Let us know if there are any other issues or suggestions 😃
Interesting. I noticed that the Auth Token is propagating through correctly but the account and message SIDs just shows up as follows:
Something weird is going on.
EDIT:
I followed the steps that @J0 posted, and I see the env variables propagating through. I haven’t tested the sms capability yet, but I will report back.
Hey Jordi,
Thanks again for the detailed setup. I tried the above steps and was able to get it to work. I did, however, swap out GoTrue with a slightly later version which returns SMS sending errors.
We currently don’t return the error on SMS sending on GoTrue v2.125.1 which can be confusing (my bad on this sorry about that). The fix has been merged and one should see clearer errors starting from next version of CLI.
I think we also translate
env()tags only for secrets. So you will need to manually input variables other thanTWILIO_AUTH_TOKEN@luisfontes if there’s no sensitive data locally could you try a database reset (e.g.
supabase db reset) and also replace the config accordingly:and let me know if it works for you?
Thank you, @J0, for looking into it!
So, to be sure, I tested again with a new Twilio Verify service account and got the same error. What I did:
pnpm install.env.examplefile and renamed it to.envTWILIO_ACCOUNT_SIDandTWILIO_AUTH_TOKENfrom my Twilio account (https://console.twilio.com/us1/account/keys-credentials/api-keys);TWILIO_VERIFY_MESSAGE_SERVICE_SIDfrom the Twilio verify service settings page (Service SID).pnpm run sb:startSUPABASE_URLandSUPABASE_ANON_KEYfrom the output of supabase start. And my personal phone number toPHONE_NUMBERnode test.jsSame message as before, the
AuthRetryableFetchError.Then I went into my supabase cloud instance and updated the Twilio tokens to be the same as the ones in the .env file. In the .env file updated the supabase vars to point to my cloud instance, and ran
node test.js. I don’t get an error and the message is sent to my phone number.I also tested replacing the
env()tags with the tokens in the config file and restarted the supabase containers, no luck.