Skip to content

Add core types & error map to auth-exp #2890

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

Merged
merged 4 commits into from
Apr 10, 2020
Merged

Conversation

avolkovi
Copy link
Contributor

@avolkovi avolkovi commented Apr 9, 2020

Hey there! So you want to contribute to a Firebase SDK?
Before you file this pull request, please read these guidelines:

Discussion

  • Read the contribution guidelines (CONTRIBUTING.md).
  • If this has been discussed in an issue, make sure to link to the issue here.
    If not, go file an issue about this before creating a pull request to discuss.

Testing

  • Make sure all existing tests in the repository pass after your change.
  • If you fixed a bug or added a feature, add a new test to cover your code.

API Changes

  • At this time we cannot accept changes that affect the public API. If you'd like to help
    us make Firebase APIs better, please propose your change in an issue so that we
    can discuss it together.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 9, 2020

Binary Size Report

Affected SDKs

No changes between base commit (85e6b06) and head commit (ff9ac63).

Test Logs

WEB_STORAGE_UNSUPPORTED = 'web-storage-unsupported'
}

const ERRORS: ErrorMap<AuthErrorCode> = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll start the discussion here - is there a way we can make this optional? All these strings will be a large part of the compiled binary

Copy link
Contributor

@sam-gc sam-gc Apr 9, 2020

Choose a reason for hiding this comment

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

As discussed offline, it might be good to have separate error maps for "dev" and "prod", that way the user could choose which gets included. That would require the AUTH_ERROR_FACTORY to not be a constant.

I think we can mull this for a while, but to make that change more straightforward in the future, maybe this module should export a function instead of a constant?

export function getErrorFactory() { return AUTH_ERROR_FACTORY }

Copy link
Contributor Author

@avolkovi avolkovi Apr 9, 2020

Choose a reason for hiding this comment

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

interested in what others think about this... @bojeil-google ?

Copy link
Member

@Feiyang1 Feiyang1 Apr 9, 2020

Choose a reason for hiding this comment

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

Just as a FYI, Firestore implemented something similar recently, but in a different way. They split their asserts into hardAsserts and debugAsserts, and debugAsserts are removed in the prod build.

#2859
#2814

I like your idea here that user could choose what errors to show.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The assert model is cool, but doesn't work great in auth since most of our error messages are translations for server side errors

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this list also includes client side errors that do not map to server side errors.
So you are suggesting to make error mapping functionality modular? So if the developer does not import it, then what happens?
Expecting the developer to know what errors to include puts a lot of burden on the developer. They would need to understand each error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think for production builds we could just have a short code that can be mapped in our documentation, something like Error: auth/email-exists, with the full description & troubleshooting tips available online

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would be a breaking API change though, and we would need the page up on the documentation before we could launch this, but it would be cool and could potentially make the final binary that much smaller

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I misunderstood your suggestion. You are suggesting modularization of the error messages population component and not the entire client side errors (and how they are mapped from server to client). That may not be terrible but a breaking change, alas.

I agree we should optimize this but I would suggest we think about it more (this also seems like a general problem and not specific to Auth). JsCore should try to find a unified solution for it. I would recommend implementing the current spec in its current form for now and then experimenting with the generated binary and revisiting this to see how we can avoid bundling these messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree on punting this to JS core for now, lets proceed as is, we can measure the possible effect of the strings during alpha and maybe implement this during beta

WEB_STORAGE_UNSUPPORTED = 'web-storage-unsupported'
}

const ERRORS: ErrorMap<AuthErrorCode> = {
Copy link
Contributor

@sam-gc sam-gc Apr 9, 2020

Choose a reason for hiding this comment

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

As discussed offline, it might be good to have separate error maps for "dev" and "prod", that way the user could choose which gets included. That would require the AUTH_ERROR_FACTORY to not be a constant.

I think we can mull this for a while, but to make that change more straightforward in the future, maybe this module should export a function instead of a constant?

export function getErrorFactory() { return AUTH_ERROR_FACTORY }

we can make an implementation class later
@sam-gc
Copy link
Contributor

sam-gc commented Apr 9, 2020

LGTM

@avolkovi avolkovi merged commit a627ebf into auth-next Apr 10, 2020
@avolkovi avolkovi deleted the avolkovi/auth-next-api branch April 16, 2020 18:07
avolkovi added a commit that referenced this pull request Apr 22, 2020
* Add core types & error map

* [AUTOMATED]: Prettier Code Styling

* [AUTOMATED]: License Headers

* User should be an interface for now

we can make an implementation class later
avolkovi added a commit that referenced this pull request Apr 23, 2020
* Add core types & error map

* [AUTOMATED]: Prettier Code Styling

* [AUTOMATED]: License Headers

* User should be an interface for now

we can make an implementation class later
avolkovi added a commit that referenced this pull request Apr 24, 2020
* Add core types & error map

* [AUTOMATED]: Prettier Code Styling

* [AUTOMATED]: License Headers

* User should be an interface for now

we can make an implementation class later
@firebase firebase locked and limited conversation to collaborators May 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants