OCM notifications without sharedSecret return 500 instead of 400

Open Beginner friendly
#67,595 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
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
api, backend

Research direction

Read apps/cloud_federation_api/lib/Controller/RequestHandlerController.php, especially receiveNotification() and resolveNotificationIdentity(), to trace how the missing sharedSecret exception is handled. Find the controller tests for OCM notifications and add coverage for a request without notification.sharedSecret. Done means that request returns 400 with the validation error instead of 500, and the test passes.

Written by the indexing model from the issue text.

Description

1. to develop bug feature: federation
Bug description

When signature checks are enabled (the default), RequestHandlerController::receiveNotification() resolves the sender identity first:

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php#L320-L331

resolveNotificationIdentity() throws a BadRequestException when the notification has no sharedSecret:

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php#L477-L481

but that try block only catches IncomingRequestException – the BadRequestException handler belongs to the next try block – so the request ends in a 500 and an uncaught exception is logged. (Embedded shares without secret are tracked in #67246.)

Steps to reproduce

Found by code reading.

  1. Send an OCM notification without notification.sharedSecret to /ocm/notifications.
  2. The response is a 500.
Expected behavior

A 400 with the validation error, covered by a test.

Nextcloud version

master

Dominant language
PHP
Stars
37.7k
Forks
5.4k
Avg merge
1d 23h
Merged PRs (30d)
585

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/server

All issues in nextcloud/server

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.