Skip to content

fix(fetcher): catch GenericFileException when reading the appstore cache file#891

Open
oleksandr-nc wants to merge 1 commit into
mainfrom
fix/exapp-fetcher-generic-file-exception
Open

fix(fetcher): catch GenericFileException when reading the appstore cache file#891
oleksandr-nc wants to merge 1 commit into
mainfrom
fix/exapp-fetcher-generic-file-exception

Conversation

@oleksandr-nc
Copy link
Copy Markdown
Contributor

Mirrors the core fix in nextcloud/server#60286: on GenericFileException (NC 35 now throws it when the appstore cache file can't be read) we drop the unreadable cache file and let it be refetched, returning [] cleanly if even deleting it fails.

Tested on NC 35 by making the cached appapi_apps.json unreadable: before, /apps/list returns 500; after, it recovers with the full list and the cache file is recreated.

…che file

Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extends cache-file error handling in AppAPIFetcher::get(). It imports OCP\Files\GenericFileException and adds a new exception handler that catches unreadable cache files (caused by permission or I/O failures). When caught, the code attempts to delete the problematic cache file, logs an error and returns an empty array if cleanup fails, or logs a warning and creates a fresh cache file to retry the content refresh if deletion succeeds.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately and concisely describes the main change: catching GenericFileException when reading the appstore cache file.
Description check ✅ Passed The pull request description is directly related to the changeset, explaining the fix, its purpose, and how it was tested.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/Fetcher/AppAPIFetcher.php (1)

154-159: ⚡ Quick win

Consider capturing the deletion exception for better diagnostics.

The inner catch (Exception) on line 156 uses PHP 8+ syntax without a variable, so the deletion failure reason is not captured. Line 157 logs the original read exception $e, which correctly identifies the root cause, but if deletion fails it would be helpful to also log why deletion failed for debugging.

💡 Optional: capture and log both exceptions
 		} catch (GenericFileException $e) {
 			// File exists but is unreadable (I/O or OS-level permission failure); drop it and refresh
 			try {
 				$file->delete();
-			} catch (Exception) {
-				$this->logger->error('Could not read appstore cache file', ['app' => 'appstoreExAppFetcher', 'exception' => $e]);
+			} catch (Exception $deleteException) {
+				$this->logger->error('Could not read or delete appstore cache file', [
+					'app' => 'appstoreExAppFetcher',
+					'read_exception' => $e,
+					'delete_exception' => $deleteException,
+				]);
 				return [];
 			}

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a34e6ab-f31b-4936-a581-e9cda87874da

📥 Commits

Reviewing files that changed from the base of the PR and between d3f84da and b7c677c.

📒 Files selected for processing (1)
  • lib/Fetcher/AppAPIFetcher.php

@oleksandr-nc
Copy link
Copy Markdown
Contributor Author

CI failures are not related

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.

1 participant