X Tutup
Skip to content

Catch setSharedWith InvalidArgumentException#37343

Closed
phil-davis wants to merge 3 commits intomasterfrom
catch-setSharedWith-InvalidArgumentException
Closed

Catch setSharedWith InvalidArgumentException#37343
phil-davis wants to merge 3 commits intomasterfrom
catch-setSharedWith-InvalidArgumentException

Conversation

@phil-davis
Copy link
Contributor

Description

POC on top of PR #37336

This PR demonstrates how we could catch an InvalidArgumentException thrown by setSharedWith if someone does an API call like:

curl --user jim:jim http://172.17.0.1:8080/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json -d '{"shareType": 0, "shareWith": 256, "permissions": 31, "path": "/faaa"}' -X POST -H "Content-Type: application/json"
{"ocs":{"meta":{"status":"failure","statuscode":403,"message":"sharedWith is integer but must be a string","totalitems":"","itemsperpage":""},"data":[]}}

So they get a 403 and error message instead of a 500 with no message.

Related Issue

#37324

How Has This Been Tested?

Needs unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@phil-davis phil-davis self-assigned this May 5, 2020
@phil-davis
Copy link
Contributor Author

@karakayasemi should we do something like this?
(in case someone makes API calls like this, so they get 403 instead of 500)

@karakayasemi
Copy link
Contributor

@karakayasemi should we do something like this?
(in case someone makes API calls like this, so they get 403 instead of 500)

Yes, this looks good. I don't know, why these exceptions are ignored before.

We can continue with this PR. Need to add an explanatory comment to ShareesController.php change as @jvillafanez suggest and correcting changelog, or I can cherry-pick the commit and include it to #37336

@phil-davis
Copy link
Contributor Author

@karakayasemi Please cherry-pick into your PR and add some unit tests etc.

@phil-davis
Copy link
Contributor Author

closing - this code will go into the parent PR

@phil-davis phil-davis closed this May 5, 2020
@phil-davis phil-davis deleted the catch-setSharedWith-InvalidArgumentException branch June 18, 2020 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup