0

I´ve been struggling to complete the Pset9 - Finance, version from 2021. After reading multiple threads I decided to post here the issue, looking for some guidance so I can move forward in the course.

Application.py is doing what the problem briefing required, and all tests were passed except for this one, check50 is expecting a status code 200 but I send a 400.

[![All tests were passed except this one][1]][1]

Some areas of thought and considerations:

  • Registration works as expected. I am able to register new users, and when the same username tries to register I show a 400 error.
  • Index function is completed, and fully functional showing all required data.
  • No script in Register.html to check username when pressing the submit button. I have been unable to write the right script. Not sure if this is something CS50 is expecting after all, but happy to hear anyone who has passed this test.

I would really appreciate it if someone can take a look at the code below, and let me know if I am doing something wrong or just point me in the right direction. Thanks in advance!

6
  • I ran check50 with this register and index functions; all passed. (The htmls should not affect this particular result). Try again? Sorry this isn't particularly helpful. Feb 2 at 1:50
  • Thanks for checking my code @DinoCoderSaurus and running those tests again. Glad to hear they passed! Would this mean any other logic within application.py is affecting check50 when performing the registration duplicate test? Here is my full code just in case you can see this easily paste.ofcode.org/FFdACSDH9KLKbpat9AXAnU After reading your comment I tried again, but I always get the same error. How can I pass this one from my end? Ans if not possible, shall I submit as it is?
    – MrTxo
    Feb 2 at 13:58
  • Can you please edit the schema definitions of users and stocks tables into the question? I ran check50 on this application.py plus register.html. It failed "register user " and the duplicate test because of a missing stocks table. I added a stocks table based on the code. Both tests passed check50. That leads me to the conclusion that the db schema (or perhaps data) is significant to the problem. Feb 2 at 19:56
  • @DinoCoderSaurus just added a schema definition of both tables and a screenshot from each structure on phplite. Let me know if this is sufficient, or if you need me to add anything else. Thanks again for your help on this one!
    – MrTxo
    Feb 2 at 20:20
  • Running check50 (version 3.2.0) on the IDE with this application.py, register.html and index.html and the two tables (empty) in finance.db passes all of the "register" tests. (and works as expected in the browser). You can find the check50 version with check50 -V. I won't stop thinking about it, which I know is no help at all. It may be time to contact sysadmins@cs50.harvard.edu Feb 3 at 0:08
1

The 'duplicate' check first registers a new user (which would return a 200) and then tries to register that same user (which would return a 400).

The error you are seeing saying it was expecting a 200 and didn't get it. That tells me that it is the initial registration that is failing.

If you delete all the rows from your user table and run check50 again, does it still fail?

2
  • 1
    Wow, that was it! I´ve been literally almost 3 weeks doing 100 different things on my code and at some point, it really looked impossible to solve but it was solved by pressing a button to empty the table. Lol. So for the record, I assume this has been caused as I already registered the very same name in the database, and once check50 tried got 400 instead of 200. I cannot thank you enough for helping me out here! THANK YOU! :)
    – MrTxo
    Feb 5 at 18:01
  • I have same error message and followed the suggestion here. My table is empty but the error message is still there. Any advice please.
    – Idongesit
    Mar 6 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .