Project

General

Profile

Bug #5743

DVR API return code

Added by Joe User 12 months ago. Updated 12 months ago.

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

History

#1

Updated by Dave Pickles 12 months ago

Many other api functions also return negative status codes, though I haven't checked if their calling function is expecting them.

#2

Updated by Joe User 12 months ago

Yes, I saw that but didn't have time (and don't have time now) to check if other calls from webui_api return negative results. Possibly the webui_api needs the change to accept negative results. Will try to look later tonight or tomorrow...

#3

Updated by Jaroslav Kysela 12 months ago

  • Status changed from New to Fixed

Fixed in v4.3-1813-gc67ba3ce1 .

Also available in: Atom PDF