Fix timeout_ms validation and write path section name consistency

1. Validate timeout_ms against the CHECK constraint (100..100000000) and
   skip routes with invalid or missing values with an error message.
   Previously, omitting timeout_ms defaulted to 0, which silently failed
   the SQLite CHECK constraint and dropped the route.

2. Update Write_Restapi_to_configfile to emit 'restapi_routes:' instead
   of 'restapi:' so save-then-reload cycles use the preferred section name
   consistently.
copilot/feature-load-restapi-routes-config
René Cannaò 2 months ago
parent bbcc67b339
commit c3564af9cf

@ -414,7 +414,7 @@ int ProxySQL_Config::Write_Restapi_to_configfile(std::string& data) {
return -1;
} else {
if (sqlite_resultset) {
data += "restapi:\n(\n";
data += "restapi_routes:\n(\n";
bool isNext = false;
for (auto r : sqlite_resultset->rows) {
if (isNext)
@ -478,6 +478,10 @@ int ProxySQL_Config::Read_Restapi_from_configfile() {
if (route.lookupValue("interval_ms", timeout_ms) == false) {
route.lookupValue("timeout_ms", timeout_ms);
}
if (timeout_ms < 100 || timeout_ms > 100000000) {
proxy_error("Admin: detected a restapi route in config file with invalid or missing timeout_ms (must be 100..100000000, got %d)\n", timeout_ms);
continue;
}
if (route.lookupValue("method", method)==false) {
proxy_error("Admin: detected a restapi route in config file without a mandatory method\n");
continue;

Loading…
Cancel
Save