Editing a Markdown file in a public share fails: TextContextProviderFactory::__construct(): Argument #5 ($userId) must be of type string, null given
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- authentication, backend
Research direction
Start with lib/Provider/TextContextProviderFactory.php and lib/Provider/TextContextProvider.php, then check how PermissionService handles a null user ID. Add a regression test in tests/unit/Provider/TextContextProviderFactoryTest.php for factory construction with null and verify build() and buildForCard() return valid contexts. Done means public share editing no longer fails with this TypeError and the regression test passes.
Written by the indexing model from the issue text.
Description
Summary
After upgrading Nextcloud (35.0.2.2), editing a Markdown file in a public share fails with a 500 error. Deck's TextContextProviderFactory is resolved by the Text app for every registered text context, and on public shares there is no logged-in user, so the DI container injects null into the non-nullable string $userId constructor parameter.
Steps to reproduce
Create a public share link for a Markdown (.md) file
Open the share and start editing the file
The sync request POST /index.php/apps/text/public/session/<id>/sync fails
Error
OCA\Deck\Provider\TextContextProviderFactory::__construct(): Argument #5 ($userId) must be of type string, null given
in /nextcloud/apps/deck/lib/Provider/TextContextProviderFactory.php line 20
Relevant trace: OCA\Text\Controller\PublicSessionController::sync → ApiService::getContext → ContextManager::getContexts → dispatchTyped(RegisterContextEvent) → ServiceEventListener → SimpleContainer::resolve(TextContextProviderFactory::class) → TypeError.
Expected behavior
Editing a Markdown file in a public share works; Deck's context factory must not crash when no user is logged in.
Proposed solution
Widen the constructor parameter to nullable in both classes, since the downstream consumer already accepts null:
lib/Provider/TextContextProviderFactory.php:25: string $userId → ?string $userId
lib/Provider/TextContextProvider.php:34: string $userId → ?string $userId
PermissionService::checkPermission(..., $userId = null) (lib/Service/PermissionService.php:172) and userCan()/userIsBoardOwner() already handle null, so with no user the context simply resolves to read-only instead of throwing a TypeError. A regression test (tests/unit/Provider/TextContextProviderFactoryTest.php) constructs the factory with null userId and asserts build()/buildForCard() still return a valid context.
Environment
Nextcloud 35.0.2.2, Deck current master, Text app public share session
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 363
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 118
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextcloud/deck
-
Federated board stacks return 500: getReadMark() called with null user in CardService::enrichCards()Open1. to develop bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nextcloud/deck#8721 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
DeckProvider::setSubjects() overwrites IEvent subject with translated sentence → InvalidValueException, Deck bell notifications silently droppedPossibly taken @tcarrondo claimed this 12 days ago. Open0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
nextcloud/deck#8591 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
CSV export leaves trailing commas in tags and assigned-user fieldsPossibly taken @Kumar-s75 claimed this 62 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
nextcloud/deck#8361 · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
home-sweet-gnome/dash-to-panel#2594 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
agentic-community/mcp-gateway-registry#2017 ·
Maintainers usually reply within 1 day
-
P2 Team S Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
google/site-kit-wp#14138 ·
Maintainers usually reply within 2 days
-
from-agent
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
immich-app/immich#33181 ·
Maintainers usually reply within 1 day