Deprecated `columns` payload on PUT /api/1/views/{viewId} always returns 500

オープン 初心者向け
#3,208 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
api, backend

調査の方向性

lib/Model/ViewUpdateInput.php の 90〜113 行目付近から始めてください。ここでは非推奨の columns 分岐が json_encode() を呼び出し、その結果の文字列を lib/Model/ColumnSettings.php の ColumnSettings::createViewSettingsFromInputArray() に渡していますが、この関数は配列を期待しています。issue にある curl PUT で再現し、そのうえで ViewColumnInformation のリストを単純な配列に正規化する必要があるか確認してください。このリクエストが 500 を返さずビューの列を更新し、新しい形式も引き続き動作すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Steps to reproduce

PUT /index.php/apps/tables/api/1/views/{viewId} with the deprecated columns payload, i.e. a plain list of column ids and no columnSettings key:

curl -u user:pass -H 'OCS-APIRequest: true' -H 'Content-Type: application/json' \
  -X PUT 'http://localhost/index.php/apps/tables/api/1/views/357' \
  -d '{"data":{"columns":[1142,1143,1144,1145]}}'
Expected behavior

The view's columns are updated, since columns is documented as the deprecated-but-supported form — ViewUpdateInput::fromInputArray() logs The old columns format is deprecated. Please use the new format with columnId and order properties. and then converts it. Failing that, a 400 Bad Request naming the problem.

Actual behavior

500 Internal Server Error, with an HTML error page rather than a JSON body. nextcloud.log:

OCA\Tables\Model\ColumnSettings::createViewSettingsFromInputArray(): Argument #1 ($inputColumnSettings)
must be of type array, string given, called in lib/Model/ViewUpdateInput.php on line 113
in file 'lib/Model/ColumnSettings.php' line 63

The conversion branch builds a ViewColumnInformation[] and then JSON-encodes it into a string (lib/Model/ViewUpdateInput.php:92-103):

$value = [];
foreach ($data['columns'] as $order => $columnId) {
    $value[] = new ViewColumnInformation($columnId, order: $order);
}
$value = json_encode($value);   // <- string

$data['columnSettings'] = $value;

and line 113 passes that string straight into a parameter typed array:

columnSettings: isset($data['columnSettings']) ? ColumnSettings::createViewSettingsFromInputArray($data['columnSettings'], $columnsMap) : null,

transformJsonToArrayInPayload(), which would decode a JSON string back into an array, runs at line 90 — before the string is produced — so it never sees this value. The deprecated path therefore cannot succeed: it throws a TypeError for every input.

Dropping the json_encode() call (keeping $value as the array it already is) is enough to make the branch work, since ColumnSettings::createViewSettingsFromInputArray() accepts exactly that shape. A ViewColumnInformation object list may still need normalising to plain arrays depending on what that method expects.

Introduced in cff2c94a ("refactor(Views): turn some details into objects with early validation", 2025-12-05), so every release from v2.0.0 onwards is affected, including current main.

Tables app version

main (reproduced at 4150d63b), also present in every tag from v2.0.0 onwards

Server operating system / environment

Nextcloud 36.0.0 dev, PHP 8.5, MySQL — nextcloud-docker-dev

Additional info

Found while seeding test data through the API; the frontend sends columnSettings and so never hits this path, which is presumably why it has gone unnoticed.

主要言語
JavaScript
スター
220
フォーク
57
平均マージ
1日 3時間
マージ済み PR(30日)
76

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nextcloud/tables のほかの issue

nextcloud/tables の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。