Actions
Bug #5743
closedDVR API return code
Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Start date:
2019-10-09
Due date:
% Done:
0%
Estimated time:
Found in version:
4.3
Affected Versions:
Description
While trying to debug a problem, I noticed all errors returned were "bad request".
Looking at the code I found:
api_dvr.c
static int api_dvr_entry_file_moved ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) { const char *src, *dst; if (!(src = htsmsg_get_str(args, "src"))) return -EINVAL; if (!(dst = htsmsg_get_str(args, "dst"))) return -EINVAL; if (dvr_entry_file_moved(src, dst)) return -ENOENT; return 0;
but in webui_api.c
/* Convert error */ if (r) { switch (r) { case EPERM: case EACCES: r = http_noaccess_code(hc); break; case ENOENT: case ENOSYS: r = HTTP_STATUS_NOT_FOUND; break; default: r = HTTP_STATUS_BAD_REQUEST; break; } }
So the negative return codes ("-") is causing the ENOENT error to be reported as "bad request" instead of "not found".
PR created: https://github.com/tvheadend/tvheadend/pull/1307
Actions