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

The first word you submit in the word guessing game in production disappears. #385

Open
vingkan opened this issue Aug 7, 2022 · 0 comments
Assignees
Labels
backend Related to the backend API bug Something isn't working

Comments

@vingkan
Copy link
Collaborator

vingkan commented Aug 7, 2022

Issue

  • The first word you submit to the word guessing game disppears.
  • This only happens in the production version of the app, not in testing.

Root Cause

The first time a game is created, the goal word is saved to the database, but this leads to a race condition when we try to read the previous state immediately after.

We fixed it in this commit where we fallback to the game instance's existing goal word, which handles the case where the game has just been created for the first time on any instance.

The API shows this error log when your guess disappears:

2022-08-07T00:28:46.341988+00:00 app[web.1]: 'NoneType' object is not subscriptable
2022-08-07T00:28:46.341996+00:00 app[web.1]: Traceback (most recent call last):
2022-08-07T00:28:46.341997+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/ninja/operation.py", line 99, in run
2022-08-07T00:28:46.341997+00:00 app[web.1]:     result = self.view_func(request, **values)
2022-08-07T00:28:46.341998+00:00 app[web.1]:   File "/app/backend/games/views/word_guesser.py", line 64, in post_guess
2022-08-07T00:28:46.341998+00:00 app[web.1]:     next_state = get_next_game_state(game, guess.word, previous_state)
2022-08-07T00:28:46.341998+00:00 app[web.1]:   File "/app/backend/games/word_guesser/state_management.py", line 14, in get_next_game_state
2022-08-07T00:28:46.341999+00:00 app[web.1]:     next_guess = game.guess_word(word)
2022-08-07T00:28:46.341999+00:00 app[web.1]:   File "/app/backend/games/word_guesser/WordGuesser.py", line 86, in guess_word
2022-08-07T00:28:46.342000+00:00 app[web.1]:     if char is goal[i]:
2022-08-07T00:28:46.342001+00:00 app[web.1]: TypeError: 'NoneType' object is not subscriptable
2022-08-07T00:28:46.342452+00:00 app[web.1]: Internal Server Error: /games/wordguesser/default/guess
2022-08-07T00:28:46.343043+00:00 app[web.1]: 10.1.34.162 - - [07/Aug/2022:00:28:46 +0000] "POST /games/wordguesser/default/guess HTTP/1.1" 500 608 
@vingkan vingkan added bug Something isn't working backend Related to the backend API labels Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to the backend API bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants