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

TypeError on login #12

Open
Necroni opened this issue Sep 5, 2022 · 1 comment
Open

TypeError on login #12

Necroni opened this issue Sep 5, 2022 · 1 comment
Labels
wontfix This will not be worked on

Comments

@Necroni
Copy link
Collaborator

Necroni commented Sep 5, 2022

Error produced on login. User does have an item in the wishlist that has price listed as a non-number - that's my first guess as to a solution. This means we'd want to sanitize data such that only numbers can be input in the wish form, maybe?

Error reads:
TypeError: /mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/views/wishlist.ejs:29
27|


  • 28|

    <%=e.wish%>

    29| Cost: $<%=e.price.toFixed(2)%>
    30| Link To Item
    31| Delete
    32|

  • Cannot read properties of undefined (reading 'toFixed')
    at eval (eval at compile (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/ejs/lib/ejs.js:673:12), :23:33)
    at Array.forEach ()
    at eval (eval at compile (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/ejs/lib/ejs.js:673:12), :12:15)
    at wishlist (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/ejs/lib/ejs.js:703:17)
    at tryHandleCache (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/ejs/lib/ejs.js:274:36)
    at View.exports.renderFile [as engine] (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/ejs/lib/ejs.js:491:10)
    at View.render (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/express/lib/view.js:135:8)
    at tryRender (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/express/lib/application.js:640:10)
    at Function.render (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/express/lib/response.js:1012:7)
    at ServerResponse.res.render (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/node_modules/express-flash/lib/express-flash.js:29:16)
    at getWishes (/mnt/d/Greg/Learning/Learn With Leon/teamproject/MVC-R1-F3-T1-V2/controllers/wishes.js:7:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

    @Necroni
    Copy link
    Collaborator Author

    Necroni commented Sep 5, 2022

    This error ONLY seems to exist if there is a wishlist item with a "price" attribute that is not a number. For example, if price: "$222" exists in a collection, this will break the login.

    Since we've now added number validation to the input (and therefore can't be repeated without directly editing the database), this issue should take a back seat to other more pressing issues.

    Possible future solution is to add a new ensureNumber function into the middleware, so that the client checks whether the input is a number before attempting to submit to the database.

    @Necroni Necroni added the wontfix This will not be worked on label Sep 5, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    wontfix This will not be worked on
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant