Repository navigation
files_external: answer invalid user-provided credentials with HTTP 400 - #41949
Open
openefaadmin wants to merge 4 commits into
Open
openefaadmin wants to merge 4 commits into
openefaadmin wants to merge 4 commits into
Conversation
UserGlobalStoragesController::update() only caught NotFoundException around saveBackendOptions()/manipulateStorageConfig(). An auth mechanism rejecting the submitted values (e.g. an empty username or password, thrown as InvalidArgumentException) or being left without usable data (InsufficientDataForMeaningfulAnswerException) therefore surfaced as a 500 server error with no message for the client. Both are client errors: return 400 with the message so the Files credentials dialog and personal settings can show it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Scott Barbour <[email protected]>
…cloud#41949) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016dZdUmLKzvEBB5zmcCPNrL Signed-off-by: Scott Barbour <[email protected]>
Contributor
|
It also looks like
|
Covers index(), show() and update() of the controller that handles a user\x27s own credentials for admin-defined mounts: the admin\x27s configuration is never returned and the password is redacted; update() answers 404 for an unknown storage, 403 when the auth mechanism is not user provided, and 400 with the reason when the auth mechanism rejects the submitted credentials or is left without usable data. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Scott Barbour <[email protected]>
… reject the options Makes the contract explicit for app authors: an auth mechanism may throw InvalidArgumentException for options it cannot accept, and files_external answers the request with HTTP 400 and the message. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Scott Barbour <[email protected]>
phil-davis
reviewed
Oct 29, 2026
| /** | ||
| * @see \OCA\Files_External\Controller\UserGlobalStoragesController | ||
| */ | ||
| class UserGlobalStoragesControllerTest extends TestCase { |
Contributor
There was a problem hiding this comment.
Should this extend StoragesControllerTest (like UserStoragesControllerTest does).
I haven't looked at the detail, but the production classes have similar extends:
class UserStoragesController extends StoragesController {
class UserGlobalStoragesController extends StoragesController {
And the existing test class:
class UserStoragesControllerTest extends StoragesControllerTest {
jvillafanez
reviewed
Oct 29, 2026
| // empty username or password): a client error, not a server error. | ||
| return new DataResponse( | ||
| [ | ||
| 'message' => (string)$this->l10n->t('Invalid credentials: %s', [$e->getMessage()]) |
Member
There was a problem hiding this comment.
Exceptions messages are expected to be in English. The resulting string will have a mix of languages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
UserGlobalStoragesController::update()only catchesNotFoundExceptionaroundsaveBackendOptions()/manipulateStorageConfig(). When the authenticationmechanism rejects the submitted values (an
InvalidArgumentException, for examplean empty username or password) or is left without usable data
(
InsufficientDataForMeaningfulAnswerException), the request ends in a 500 withno message. Both are client errors: return 400 with the message so the Files
credentials dialog and the personal storage settings can show it.
Related Issue
No open issue; found while testing a user-provided authentication mechanism
against the
userglobalstoragesendpoint.Motivation and Context
A user who submits an empty password in the Files credentials dialog gets a
generic server error instead of being told what is wrong, and the server log
records a 500 for a client mistake.
How Has This Been Tested?
user-provided password mechanism
password: before 500 with an HTML error page, after 400 with
{"message":"Invalid credentials: ..."}
Generated with Claude Code