Skip to content

feat: demo smallest possible hooks change #2019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hf
Copy link
Contributor

@hf hf commented May 12, 2025

What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

What is the current behavior?

Please link any relevant issues here.

What is the new behavior?

Feel free to include screenshots if it includes visual changes.

Additional context

Add any other context or screenshots.

@hf hf force-pushed the hf/demo-smallest-possible-change branch from c1429b2 to 5221c72 Compare May 12, 2025 16:58
@cstockton
Copy link
Contributor

cstockton commented May 13, 2025

I appreciate you doing this and If you want to fully test and implement this in a future pull request I won't protest. But I can not justify turning my 2 simple trigger calls with 10-15 function calls with flags for control flow in the middle of 200-300+ line functions. I just am not seeing the reasoning here Stojan, apologies.

It also shows how easy it is to overlook the control flow and miss something, like you did here:
https://github.com/supabase/auth/blob/5221c72f895b795843c29c076389964256f572f1/internal/api/signup.go#L305C1-L327C3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look very closely at your pr, but it's currently not implemented fully.

Please note this is being called within a transaction, you need to propagate the decisions to run the trigger from within internalExternalProviderCallback to all callers as seen below:

/ws/src/auth/internal/api % rg createAccountFromExternalIdentity
external.go
219:			if user, terr = a.createAccountFromExternalIdentity(tx, r, userData, providerType); terr != nil {
271:func (a *API) createAccountFromExternalIdentity(tx *storage.Connection, r *http.Request, userData *provider.UserProvidedData, providerType string) (*models.User, error) {

token_oidc.go
231:		user, terr = a.createAccountFromExternalIdentity(tx, r, userData, providerType)

web3.go
134:		user, terr := a.createAccountFromExternalIdentity(tx, r, &userData, "web3")

samlacs.go
289:		if user, terr = a.createAccountFromExternalIdentity(tx, r, &userProvidedData, "sso:"+ssoProvider.ID.String()); terr != nil {

So it goes from 1 in signupNewUser, to 5 places that each require careful consideration and potentially will require propagating up N more calls. I will also need to write unit tests that call deep into samlacs, web3 and external. This is a massive amount of work when you begin to truly think through your changes.

Keep in mind this is just 1 hook. Next up is identity which is even more complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants