nextcloud / nextcloud/sharereview
Bug: ShareReview fails when Analytics app is enabled due to unhandled TypeError
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 15
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
When the Analytics app is enabled, ShareReview fails to load /apps/sharereview/data/new and throws an exception.
Disabling the Analytics app immediately resolves the issue and ShareReview works normally again.
The exception originates from OCA\Analytics\ShareReview\ShareReviewSource::getSourceName(), which returns null although the method is declared to return a string.
The exception is currently not handled by ShareReview and prevents the API endpoint from returning results.
Steps to reproduce
-
Install and enable:
- ShareReview
- Analytics
-
Open ShareReview or trigger:
/index.php/apps/sharereview/data/new
-
Observe that the request fails with an exception.
-
Disable Analytics:
php occ app:disable analytics
-
Repeat the request.
-
ShareReview works normally again.
Expected behavior
ShareReview should continue to work even if another app returns invalid or unexpected data.
External providers should be treated defensively:
- ignore invalid entries
- catch exceptions
- continue processing remaining sources
A failure in one provider should not break the whole ShareReview endpoint.
Actual behavior
The request fails with:
TypeError:
OCA\Analytics\ShareReview\ShareReviewSource::getSourceName():
Return value must be of type string, null returned
and the endpoint returns an exception instead of share information.
Environment
- Nextcloud version: 33.0.3.2
- ShareReview: latest available version
- Analytics: latest available version
Stack trace
TypeError:
OCA\Analytics\ShareReview\ShareReviewSource::getSourceName():
Return value must be of type string, null returned
#0 apps/analytics/lib/ShareReview/ShareReviewSource.php(74)
#1 apps/sharereview/lib/Service/ShareService.php(317)
#2 apps/sharereview/lib/Service/ShareService.php(65)
#3 apps/sharereview/lib/Controller/OutputController.php(64)
#4 lib/private/AppFramework/Http/Dispatcher.php(205)
...
Additional information
The issue disappears completely when the Analytics app is disabled.
This suggests that ShareReview currently assumes that all providers always return valid data and does not guard against exceptions originating from provider implementations.
It may be beneficial to wrap calls to app providers in a try/catch block and skip invalid sources instead of aborting the entire request.
Contributor 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.
Research direction
Start in apps/sharereview/lib/Service/ShareService.php around lines 317 and 65, then inspect the provider implementation at apps/analytics/lib/ShareReview/ShareReviewSource.php around line 74. Reproduce /index.php/apps/sharereview/data/new with both apps enabled; done means an invalid provider result or exception is skipped and the endpoint still returns share information from remaining sources.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100