nextcloud / nextcloud/tables

/api/2/tables/scheme/23: 500 Internal Server Error at TableService::enhanceTable

Open
#2,383 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage bug
Dominant language
JavaScript
Stars
214
Forks
52
Avg merge
1d 10h
Merged PRs (30d)
82

Description

Steps to reproduce
  1. Open OCS API viewer in Nextcloud
  2. Expand GET /ocs/v2.php/apps/tables/api/2/tables/scheme/{id}
  3. Enter table ID and click "Execute"
Expected behavior

I get the table schema back

Actual behavior

I get an error:

{
  "ocs": {
    "meta": {
      "status": "failure",
      "statuscode": 996,
      "message": "Internal Server Error\n"
    },
    "data": []
  }
}

The log contains the error:

OCA\Tables\Service\TableService::enhanceTable(): Argument #2 ($userId) must be of type string, null given, called in /var/www/cloud.example.com/apps/tables/lib/Service/TableService.php on line 555 in file '/var/www/cloud.mogic.com/apps/tables/lib/Service/TableService.php' line 163

The trace:

"Exception": "TypeError",
"Message": "OCA\Tables\Service\TableService::enhanceTable(): Argument #2 ($userId) must be of type string, null given, called in /var/www/cloud.mogic.com/apps/tables/lib/Service/TableService.php on line 555",
"Code": 0,
"Trace": [
    {
        "file": "/var/www/cloud.example.com/apps/tables/lib/Service/TableService.php",
        "line": 555,
        "function": "enhanceTable",
        "class": "OCA\Tables\Service\TableService",
        "type": "->"
    },
    {
        "file": "/var/www/cloud.example.com/apps/tables/lib/Controller/ApiTablesController.php",
        "line": 115,
        "function": "getScheme",
        "class": "OCA\Tables\Service\TableService",
        "type": "->"
    },
    {
        "file": "/var/www/cloud.example.com/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 204,
        "function": "showScheme",
        "class": "OCA\Tables\Controller\ApiTablesController",
        "type": "->"
    },
    {
        "file": "/var/www/cloud.example.com/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 118,
        "function": "executeController",
        "class": "OC\AppFramework\Http\Dispatcher",
        "type": "->"
    },
[...]
Tables app version

1.0.3

Browser

Firefox 148.0

Client operating system

Debian 13

Operating system

No response

Web server

Apache

PHP engine version

PHP 8.2

Database

MariaDB

Additional info

While I see this on 1.0.3, I believe that it still exists in v1.0.5 of nextcloud tables:

  • TableService::getScheme() has a nullable userId: ?string $userId = null
  • it calls TableService::enhanceTable() which requires a string $userId and does not allow null there.

https://github.com/nextcloud/tables/blob/701da21f4bf7ff45861e95afd82675754774a12e/lib/Service/TableService.php#L552-L555
https://github.com/nextcloud/tables/blob/701da21f4bf7ff45861e95afd82675754774a12e/lib/Service/TableService.php#L167

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/Service/TableService.php at getScheme() around line 555 and enhanceTable() around line 163, then review the call from lib/Controller/ApiTablesController.php. Reproduce GET /ocs/v2.php/apps/tables/api/2/tables/scheme/{id} through the OCS API viewer; done means the endpoint returns the table schema instead of a 500 error caused by the nullable user ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.