AttorneyOnlineVidya / tsuserver3

An Attorney Online server.
GNU Affero General Public License v3.0
2 stars 7 forks source link

Type confusion of user_data in "database" #23

Open OmniTroid opened 6 years ago

OmniTroid commented 6 years ago

There appears to be some type confusion in the field Database.user_data as evidenced by

https://github.com/AttorneyOnlineVidya/tsuserver3/blob/32657d5dce03bb0aeda5e745b8bc9dc2647ff5e6/server/database.py#L85-L97

As declared in line 36, it appears data is supposed to be a dict, but on line 94 (if the file does not exist), it writes an empty list into the file (there's also just an empty list in the default config) which yaml interprets as a Python list and loads into memory.

However, this causes issues down the line because some places call user_data[key] where key is of type str, being a TypeError. An example where user_data is clearly called with a str index is

https://github.com/AttorneyOnlineVidya/tsuserver3/blob/32657d5dce03bb0aeda5e745b8bc9dc2647ff5e6/server/database.py#L140-L142

Where ipid is of type str when it's called (seems to be a hash of the IP address).

How to reproduce: I just cloned, copied config_default to config, started it and tried to join with a client then got TypeErrors on the statement above.

Python version is 3.6.6 and AO client version is 2.4.10

DoctorMalboro commented 5 years ago

I can confirm I have the same issue when I pull a cloned copy of the repository.