@cryptotaxi247 / netdata-1 / commits / 3900523ae

improve the error message when accessing functions (#16692)

Costa Tsaousis committed Dec 29, 2023 at 15:37 UTC 3900523aea889c6bf1cd29abfe8e66c438cfe72b
1 file changed +8 -1
database/rrdfunctions.c
+8 -1
@@ -774,7 +774,14 @@ int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s, HTTP_ACCES
774 struct rrd_host_function *rdcf = dictionary_acquired_item_value(host_function_acquired);
775
776 if(access != HTTP_ACCESS_ADMINS && rdcf->access != HTTP_ACCESS_ANY && access > rdcf->access) {
777 - rrd_call_function_error(result_wb, "This function requires a higher access level.", code);
777 +
778 + if(!aclk_connected)
779 + rrd_call_function_error(result_wb, "This Netdata must be connected to Netdata Cloud to access this function.", HTTP_RESP_PRECOND_FAIL);
780 + else if(access >= HTTP_ACCESS_ANY)
781 + rrd_call_function_error(result_wb, "You need to login to the Netdata Cloud space this agent is claimed to, to access this function.", HTTP_RESP_PRECOND_FAIL);
782 + else /* if(access < HTTP_ACCESS_ANY && rdcf->access < access) */
783 + rrd_call_function_error(result_wb, "To access this function you need to be an admin in this Netdata Cloud space.", HTTP_RESP_PRECOND_FAIL);
784 +
785 dictionary_acquired_item_release(host->functions, host_function_acquired);
786 return HTTP_RESP_PRECOND_FAIL;
787 }