MegaAntiCheat / client-backend

GNU General Public License v3.0
119 stars 25 forks source link

Error 422 on late bytes upload #175

Closed megascatterbomb closed 1 month ago

megascatterbomb commented 1 month ago

Several users have reported intermittent 422 errors when uploading the late bytes.

image

Not critical as it doesn't affect our ability to parse the demo (it can even be played back in TF2 still), but still worth investigating.

jayceslesar commented 1 month ago

I am seeing this a bunch -- seems wack

"POST /late_bytes?api_key=some_api_key HTTP/1.1" 422 Unprocessable Entity
jayceslesar commented 1 month ago

I think if we make this logic better in terms of verbosity when it matters we will get some more info https://github.com/MegaAntiCheat/masterbase/blob/main/masterbase/app.py#L383

jayceslesar commented 1 month ago

there seems to be no rhyme or reason with patterns for a given api key -- some will succeed and others will fail

JoshuaVandaele commented 1 month ago

Could this be related to the "Auto-delete recordings" option? image

megascatterbomb commented 1 month ago

Could this be related to the "Auto-delete recordings" option? image

I've encountered this error a few times myself and I don't have that setting checked.

jayceslesar commented 1 month ago

I am struggling to reproduce locally

jayceslesar commented 1 month ago

The only way it would fail validation is if the body isnt a string

jayceslesar commented 1 month ago

reference https://github.com/MegaAntiCheat/client-backend/blob/main/src/masterbase.rs#L232

jayceslesar commented 1 month ago

This smells like a race condition on the DB/filesystem side as I cannot reproduce with what I believe to be valid data

jayceslesar commented 1 month ago

note that we return a 422 if we get an error when attempting to close the late bytes out ... https://github.com/MegaAntiCheat/masterbase/blob/main/masterbase/app.py#L128

likely we are hitting https://github.com/MegaAntiCheat/masterbase/blob/main/masterbase/lib.py#L559 but I just added logs to show more detail

jayceslesar commented 1 month ago

yes is indeed a race condition on the backend. Closing this issue and will eventually reproduce and fix

Familex commented 1 month ago

got these errors too:

2024-08-13T05:26:32.011520Z  INFO client_backend::demo: Opened new demo session with Masterbase: DemoSession(229295141473228488338479370295583856718)
2024-08-13T06:04:35.083956Z ERROR client_backend::demo: Failed to upload late bytes to masterbase: Server returned 422
2024-08-13T06:04:37.021542Z  INFO client_backend::masterbase: Closed session 229295141473228488338479370295583856718.
2024-08-13T06:05:08.936735Z  INFO client_backend::demo: Opened new demo session with Masterbase: DemoSession(312197181810514410830725529466809385660)
2024-08-13T06:31:51.085087Z ERROR client_backend::demo: Failed to upload late bytes to masterbase: Server returned 422
2024-08-13T06:31:52.835987Z  INFO client_backend::masterbase: Closed session 312197181810514410830725529466809385660.