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

eventhandler Config::get returns "-nan" for param1 on nonexisting/default keys #525

Open
river-etoa opened this issue May 14, 2022 · 4 comments
Assignees

Comments

@river-etoa
Copy link
Contributor

std::string Config::get returns -nan and this fucks up Config::nget, which ultimately results in

ERR: MySQL: Unexpected query error: Unknown column 'nan' in 'field list'

it works for value (p0) and param2 for some reason but not for param1.

issue is in default constructor / return values for std::map<std::string, int> sConfig and std::vector<std::vector<std::string> > cConfig due to incorrect assumptions on how c++ container initialization, object assignment and default return values work.

All this gets triggered by the underlying incorrect assumption in the eventhandler that every possible config value has an entry in the DB, whereas the frontend only seems to put non-default config values in the DB and uses the default values from XML in some places(?).

@river-etoa
Copy link
Contributor Author

this took me 4h to find ffs

@A-A-G
Copy link
Contributor

A-A-G commented May 14, 2022

Wouldn't a better fix be writing also default values to the DB?

@river-etoa
Copy link
Contributor Author

Yes, but:

  • that's not the eventhandler's job
  • there still needs to be a fallback mechanism in the eventhandler

the current eventhandler code assumes cConfig is always a vector of size 3, which is broken in Config::get without this patch. better idea would be to refactor the config code.

@river-etoa
Copy link
Contributor Author

did some code refactor with ee21169.
now uses a single map, and the value is a fixed-size array instead of a var-length vector to avoid undefined elements.

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