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

fix: omit password length validation, as hashed passwords are longer than that #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WimTibackx
Copy link

@WimTibackx WimTibackx commented Jun 8, 2024

When creating an account with the password length validation active, I get the following error. The validation is applied to the hashed password and a bcrypt hashed password is 59 or 60 characters long, thus this will always be too long. It seems more sensible to completely omit the length validation, given that all other samples don't have it either.

Error calling enhanced Prisma method `user.create`: denied by policy: user entities failed 'create' check, input failed validation: Validation error: String must contain at most 32 character(s) at "password"
    at default (C:/px/zenstack/sample-todo-sveltekit/src/routes/(auth)/signup/+page.server.ts:27:34),
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5),
    at async Module.handle_action_json_request (C:/px/zenstack/sample-todo-sveltekit/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js:57:16),
    at async resolve (C:/px/zenstack/sample-todo-sveltekit/node_modules/@sveltejs/kit/src/runtime/server/respond.js:412:18),
    at async Module.respond (C:/px/zenstack/sample-todo-sveltekit/node_modules/@sveltejs/kit/src/runtime/server/respond.js:279:20),
    at async file:///C:/px/zenstack/sample-todo-sveltekit/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:505:22 {
  name: 'PrismaClientKnownRequestError',
  code: 'P2004',
  clientVersion: '2.1.2',
  meta: {
    reason: 'DATA_VALIDATION_VIOLATION',
    zodErrors: ZodError: [
      {
        "code": "too_big",
        "maximum": 32,
        "type": "string",
        "inclusive": true,
        "exact": false,
        "message": "String must contain at most 32 character(s)",
        "path": [
          "password"
        ]
      }
    ]
        at get error [as error] (C:\px\zenstack\sample-todo-sveltekit\node_modules\zod\lib\types.js:43:31)
        at PolicyProxyHandler.validateCreateInputSchema (C:\px\zenstack\sample-todo-sveltekit\node_modules\@zenstackhq\runtime\enhancements\policy\handler.js:341:153)
        at PolicyProxyHandler.<anonymous> (C:\px\zenstack\sample-todo-sveltekit\node_modules\@zenstackhq\runtime\enhancements\policy\handler.js:142:38)
        at Generator.next (<anonymous>)
        at C:\px\zenstack\sample-todo-sveltekit\node_modules\@zenstackhq\runtime\enhancements\policy\handler.js:9:71
        at new Promise (<anonymous>)
        at __awaiter (C:\px\zenstack\sample-todo-sveltekit\node_modules\@zenstackhq\runtime\enhancements\policy\handler.js:5:12)
        at C:\px\zenstack\sample-todo-sveltekit\node_modules\@zenstackhq\runtime\enhancements\policy\handler.js:134:94
        at fullDb.$transaction.maxWait (C:\px\zenstack\sample-todo-sveltekit\node_modules\@zenstackhq\runtime\enhancements\query-utils.js:36:24)
        at Proxy._transactionWithCallback (C:\px\zenstack\sample-todo-sveltekit\node_modules\@prisma\client\runtime\library.js:127:9540) {
      issues: [Array],
      addIssue: [Function (anonymous)],
      addIssues: [Function (anonymous)],
      errors: [Array]
    }
  },
  internalStack: 'Error calling enhanced Prisma method `user.create`: denied by policy: user entities failed \'create\' check, input failed validation: Validation error: String must contain at most 32 character(s) at "password"\n' +
    '    at OmitHandler.<anonymous> (C:\\px\\zenstack\\sample-todo-sveltekit\\node_modules\\@zenstackhq\\runtime\\enhancements\\proxy.js:43:60),\n' +
    '    at Generator.next (<anonymous>),\n' +
    '    at fulfilled (C:\\px\\zenstack\\sample-todo-sveltekit\\node_modules\\@zenstackhq\\runtime\\enhancements\\proxy.js:6:58),\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)'
}

Summary by CodeRabbit

  • Refactor
    • Removed the password length constraint from the User model.

Copy link

vercel bot commented Jun 8, 2024

@WimTibackx is attempting to deploy a commit to the ZenStack Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

coderabbitai bot commented Jun 8, 2024

Walkthrough

The recent updates involve removing the @length(6, 32) constraint from the password field in the User model across two files: prisma/schema.prisma and schema.zmodel. This change simplifies the password field definition by eliminating the minimum and maximum length requirements.

Changes

Files Change Summary
prisma/schema.prisma Removed the @length(6, 32) attribute from the password field in User model.
schema.zmodel Removed the @length(6, 32) attribute from the password field in User model.

Poem

In the code where passwords lay,
Constraints have gone away.
Now more free, the fields do sing,
Simpler rules, a lighter spring.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9d8ee95 and b522d29.

Files selected for processing (2)
  • prisma/schema.prisma (1 hunks)
  • schema.zmodel (1 hunks)
Files skipped from review due to trivial changes (2)
  • prisma/schema.prisma
  • schema.zmodel

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.

1 participant