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

Open Beginner friendly
#8,721 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

The crash is in CardService::enrichCards() in lib/Service/CardService.php, where getReadMark() is called with a null user when a card has comments. Read the Comments Manager getReadMark() signature in Nextcloud core, then find where the stacks endpoint builds the user for federated requests. Done when a request without a logged-in user returns the stack without a TypeError, and the unread-comment count is handled as 0 or skipped.

Written by the indexing model from the issue text.

Description

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.

Dominant language
JavaScript
Stars
1.4k
Forks
363
Avg merge
1d 5h
Merged PRs (30d)
116

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from nextcloud/deck

All issues in nextcloud/deck

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.