Skip to content
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

feat: add parameter guards #117

Merged

Conversation

ctran88
Copy link
Contributor

@ctran88 ctran88 commented Dec 9, 2024

What's New?

  • Adds parameter guards for all Auth and User operations to simplify input checks that can be done before making a network request
  • Guards for the deprecated create magic link method are not added because it relies on default values from our API to execute without exception, so adding exceptions here would be a breaking change
  • Guards for the new create magic link method are not added because the type safety prohibits incorrect values

Screenshots (if appropriate):

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have manually tested my code thoroughly
  • I have added/updated inline documentation for public facing interfaces if relevant
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing integration and unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional context

@ctran88 ctran88 force-pushed the PSG-5515-parameter-guards branch from fd95061 to 4671f8c Compare December 9, 2024 20:26
@ctran88 ctran88 marked this pull request as ready for review December 9, 2024 20:26
@ctran88 ctran88 requested a review from a team December 9, 2024 21:44
Comment on lines 65 to 71
if isinstance(args, MagicLinkWithEmailArgs):
payload["email"] = args.email
elif isinstance(args, MagicLinkWithPhoneArgs):
payload["phone"] = args.phone
elif isinstance(args, MagicLinkWithUserArgs):
payload["user_id"] = args.user_id
payload["channel"] = args.channel
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the first 2 branches here also be setting a "channel" value in the payload?

Copy link
Contributor Author

@ctran88 ctran88 Dec 11, 2024

Choose a reason for hiding this comment

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

good catch. they should be hardcoding the channel to email and phone, respectively (i forgot about to include that piece of logic in my decision record).

i think i wrote this code before the codegen update was merged too, so i forgot to change it from a dict to the actual correct class. wasn't able to do that before because the validators would fail since all the fields were required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, this branch was supposed to be based off of #114 , so this piece of code was updated in that PR with commit 9449d08

@ctran88 ctran88 force-pushed the PSG-5515-parameter-guards branch from 69746d9 to 5315827 Compare December 11, 2024 03:27
@ctran88 ctran88 changed the base branch from main to PSG-5183-update-create-magic-link-signature December 11, 2024 04:15
@ctran88 ctran88 force-pushed the PSG-5183-update-create-magic-link-signature branch from a22485f to 20348c0 Compare December 11, 2024 04:16
@ctran88 ctran88 force-pushed the PSG-5515-parameter-guards branch from 5315827 to e9caf88 Compare December 11, 2024 04:17
@ctran88 ctran88 force-pushed the PSG-5515-parameter-guards branch from e9caf88 to 93507f7 Compare December 11, 2024 04:19
Copy link

@ctran88 ctran88 merged commit 2d1b109 into PSG-5183-update-create-magic-link-signature Dec 11, 2024
6 checks passed
@ctran88 ctran88 deleted the PSG-5515-parameter-guards branch December 11, 2024 16:24
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.

3 participants