nextcloud / nextcloud/sharereview

Bug: ShareReview fails when Analytics app is enabled due to unhandled TypeError

Open
#58 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  1. Install and enable:

    • ShareReview
    • Analytics
  2. Open ShareReview or trigger:

/index.php/apps/sharereview/data/new
  1. Observe that the request fails with an exception.

  2. Disable Analytics:

php occ app:disable analytics
  1. Repeat the request.

  2. 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

Open the contributing guide

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.