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

Error handling on shared links #21

Open
androidkotlindev opened this issue Feb 21, 2022 · 3 comments
Open

Error handling on shared links #21

androidkotlindev opened this issue Feb 21, 2022 · 3 comments

Comments

@androidkotlindev
Copy link
Contributor

androidkotlindev commented Feb 21, 2022

In some cases, there is no error handling for Sanuli game links.

This also shows if this issue is fixed in my fork.

Failed game: RIHLA|OIKEAPITSAMIINALUUTARUUSURALLIRALLI; completely working

Succeeded game: TUNKU|OIKEAKUULUTUKKUTUNKU; completely working

Over 6 guesses: RIHLA|OIKEAPITSAMIINALUUTARUUSURALLIRALLI; a black screen and 2 error messages in the console [1, 2]. Not fixed.

No quesses: RIHLA|; a black screen and 2 error messages in the console [3, 2]. Not fixed.

Forbidden characters in quesses: RIHLA|ÅÅÅÅÅ55555+++++ÂÂÂÂÂ😀😀😀😀😀ЙЙЙЙЙ; a black screen and 2 error messages in the console [3, 2] (after testing I could find that the characters causing the problems were the 😀 and the Й; the game was completely working when they were removed). Not fixed.

Forbidden characters on the right word: Å5+Â😀|OIKEAPITSAMIINALUUTARUUSURALLIRALLI; weird rendering at the "viewing screen, shows the correct word as "Ã5+ÃÐ" and on the guessing screen there is also weird rendering, and the word requires 10 characters (and is impossible to quess). Fixed as a by-product of quotient checking, this probably should be investigated further if it causes any problems within normal gameplay which it causes if the shared link is invalid (a crash).

4-char words: RIHL|OIKEPITSMIINLUUTRUUSRALLRALL; a black screen and 2 error messages in the console [1, 2]

6-char words (not in word lists): RIHLAA|OIKEAAPITSAAMIINAALUUTAARUUSUARALLIARALLIA; a black screen and 2 error messages in the console [1, 2]

Random text: (not encoded in base64) RANDOMTEXT; Redirects to the last played gamemode

(this list is not complete (yet); I will add more game links later)

Console error messages:
1:
panicked at 'index out of bounds: the len is 6 but the index is 6', src/sanuli.rs:697:22

Stack:

Error
at imports.wbg.__wbg_new_693216e109162396 (https://sanuli.fi/index-fb0d4eb7f7e0dd71.js:410:19)
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[1287]:0x4f377
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[362]:0x3b982
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[892]:0x4c962
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[531]:0x4201e
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[915]:0x4d053
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[293]:0x36ab5
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[101]:0x6008
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[140]:0x1eda5
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[119]:0x17e48

imports.wbg.__wbg_error_09919627ac0992f5 @ index-fb0d4eb7f7e0dd71.js:422

2:
Uncaught (in promise) RuntimeError: unreachable
at index-fb0d4eb7f7e0dd71_bg.wasm:0x3b9a1
at index-fb0d4eb7f7e0dd71_bg.wasm:0x4c962
at index-fb0d4eb7f7e0dd71_bg.wasm:0x4201e
at index-fb0d4eb7f7e0dd71_bg.wasm:0x4d053
at index-fb0d4eb7f7e0dd71_bg.wasm:0x36ab5
at index-fb0d4eb7f7e0dd71_bg.wasm:0x6008
at index-fb0d4eb7f7e0dd71_bg.wasm:0x1eda5
at index-fb0d4eb7f7e0dd71_bg.wasm:0x17e48
at index-fb0d4eb7f7e0dd71_bg.wasm:0x197a5
at index-fb0d4eb7f7e0dd71_bg.wasm:0x4eef9

3:
index-fb0d4eb7f7e0dd71.js:422 panicked at 'index out of bounds: the len is 6 but the index is 6', src/sanuli.rs:685:22

Stack:

Error
at imports.wbg.__wbg_new_693216e109162396 (https://sanuli.fi/index-fb0d4eb7f7e0dd71.js:410:19)
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[1287]:0x4f377
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[362]:0x3b982
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[892]:0x4c962
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[531]:0x4201e
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[915]:0x4d053
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[293]:0x36ae6
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[101]:0x6008
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[140]:0x1eda5
at https://sanuli.fi/index-fb0d4eb7f7e0dd71_bg.wasm:wasm-function[119]:0x17e48

imports.wbg.__wbg_error_09919627ac0992f5 @ index-fb0d4eb7f7e0dd71.js:422

@Cadiac
Copy link
Owner

Cadiac commented Feb 22, 2022

Improving the error handling at the shared game links would definitely be nice, now there's hardly any handling and the cases highlighted by you indeed all fail. The reason for the format to be as it is was to get easily fairly short URLs containing all the required data, but that are not human readable.

Opening the shared game can fail on multiple levels:

  1. At javascript land while trying to read the query parameter + converting the base64 to string using window.atob: https://github.com/Cadiac/sanuli/blob/master/src/manager.rs#L329
  2. At rust land while for instance splitting the string at "|" or while splitting the guesses back to chunks of n character words: https://github.com/Cadiac/sanuli/blob/master/src/sanuli.rs#L138
  3. At game logic level, for instance by having a word that can't be solved.

If support for generating links to arbitrary custom games etc is desired then the validation should be improved on all those levels.

@androidkotlindev
Copy link
Contributor Author

androidkotlindev commented Feb 22, 2022

I can fully understand your reasonings about this; but I'll probably make a pull request about this soon. (can't get Rust working)

@androidkotlindev
Copy link
Contributor Author

androidkotlindev commented Feb 22, 2022

Some checks that could be done:
Divide the char count in the guess section by the char count of the answer word and check if the answer is whole

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

No branches or pull requests

2 participants