Federated board stacks return 500: getReadMark() called with null user in CardService::enrichCards()

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

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

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

評価

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

調査の方向性

クラッシュは lib/Service/CardService.php の CardService::enrichCards() で発生します。カードにコメントがあると、ユーザーが null の状態で getReadMark() が呼び出されます。Nextcloud コアの Comments Manager にある getReadMark() のシグネチャを読み、その後、フェデレーションリクエスト向けに stacks エンドポイントがユーザーをどこで構築しているかを調べてください。ログイン済みユーザーのないリクエストが TypeError なしでスタックを返し、未読コメント数が 0 として扱われるか、スキップされれば完了です。

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

説明

How to use GitHub
  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Describe the bug
When a board is shared through Deck federation, the remote server's request for the board's stacks fails with HTTP 500 on the owning server whenever a card in the stack has comments. The owning server logs:

OC\Comments\Manager::getReadMark(): Argument #3 ($user) must be of type OCP\IUser, null given,
called in custom_apps/deck/lib/Service/CardService.php on line 88

The federated request (user agent Nextcloud-Server-Crawler/34.0.5) has no logged-in user, so $user is null. CardService::enrichCards() passes it straight to getReadMark() whenever $countComments > 0. The same line is unchanged on main.

On the remote server this surfaces as DeckFederationProxy exceptions (Server error: GET .../ocs/v2.php/apps/deck/api/v1.0/stacks/<id> resulted in a 500), and the federated board does not load for its users.

To Reproduce

  1. On server A, create a board with a stack containing a card that has at least one comment.
  2. Share the board with a user on server B via federation.
  3. As the user on server B, open the federated board.
  4. Server B logs a 500 from GET /ocs/v2.php/apps/deck/api/v1.0/stacks/<id> on server A; server A logs the getReadMark() TypeError above.

Expected behavior
Stacks load for federated users. Unread-comment counts could be skipped (or treated as 0) when there is no local user.

Suggested fix
In CardService::enrichCards(), only call getReadMark() when $user !== null:

$lastRead = ($countComments > 0 && $user !== null)
    ? $this->commentsManager->getReadMark('deckCard', (string)$card->getId(), $user)
    : null;
Server details
  • Nextcloud: 34.0.5 (official Docker image)
  • Deck: 1.18.5 on the owning server, 1.18.6 on the remote servers
  • Database: MariaDB 10.11
  • PHP: as shipped in nextcloud:34.0.5

Log entry on the owning server (trimmed):

"app":"deck","method":"GET","url":"/ocs/v2.php/apps/deck/api/v1.0/stacks/14",
"userAgent":"Nextcloud-Server-Crawler/34.0.5","version":"34.0.5.1",
"Exception":"Exception","Message":"OC\\Comments\\Manager::getReadMark(): Argument #3 ($user) must be of type OCP\\IUser, null given, called in /var/www/html/custom_apps/deck/lib/Service/CardService.php on line 88 in file '/var/www/html/lib/private/Comments/Manager.php' line 1437"

29 occurrences on the owning server in the last week.

主要言語
JavaScript
スター
1.4k
フォーク
363
平均マージ
1日 5時間
マージ済み PR(30日)
116

環境構築

Codespaces で開く

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

はじめの一歩

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

nextcloud/deck のほかの issue

nextcloud/deck の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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