Skip to content

fix(appstore): catch GenericFileException when reading cache file in Fetcher#60286

Open
miaulalala wants to merge 1 commit into
masterfrom
fix/noid/appstore-fetcher-generic-file-exception
Open

fix(appstore): catch GenericFileException when reading cache file in Fetcher#60286
miaulalala wants to merge 1 commit into
masterfrom
fix/noid/appstore-fetcher-generic-file-exception

Conversation

@miaulalala
Copy link
Copy Markdown
Contributor

@miaulalala miaulalala commented May 10, 2026

Summary

When the appstore cache file exists but file_get_contents returns false, OC\Files\Node\File::getContent() throws a GenericFileException. This exception was not caught by Fetcher::get(), which only caught NotFoundException, causing the entire apps settings page to crash with an unhandled exception.

Fix: catch GenericFileException alongside NotFoundException, log a warning, recreate the cache file, and proceed to fetch fresh data from the appstore — same recovery path as when the file is absent.

Test plan

  • Added unit test testGetWithUnreadableCacheFileRecreatesAndFetches in FetcherBase that mocks getContent() throwing GenericFileException and asserts the fetcher recovers and returns fresh data
  • All existing fetcher tests still pass (35/35)

🤖 Generated with Claude Code

@miaulalala miaulalala requested a review from a team as a code owner May 10, 2026 10:20
@miaulalala miaulalala requested review from ArtificialOwl, leftybournes, provokateurin and salmart-dev and removed request for a team May 10, 2026 10:20
@miaulalala miaulalala self-assigned this May 10, 2026
@miaulalala miaulalala added this to the Nextcloud 34 milestone May 10, 2026
@miaulalala miaulalala force-pushed the fix/noid/appstore-fetcher-generic-file-exception branch from 3c382fb to ee78276 Compare May 10, 2026 10:22
@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable33

@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable32

@miaulalala miaulalala requested review from blizzz and icewind1991 May 10, 2026 10:30
Copy link
Copy Markdown
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

I don't think this makes any sense.

Comment thread lib/private/App/AppStore/Fetcher/Fetcher.php Outdated
Comment thread lib/private/App/AppStore/Fetcher/Fetcher.php Outdated
…Fetcher

When the appstore cache file exists but file_get_contents returns false
(e.g. empty or corrupted file), a GenericFileException is thrown but was
not caught, crashing the apps settings page. Recreate the file and
proceed to fetch fresh data, same as when the file is absent.

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@miaulalala miaulalala force-pushed the fix/noid/appstore-fetcher-generic-file-exception branch from ee78276 to 01807e4 Compare May 12, 2026 16:36
@miaulalala miaulalala requested a review from provokateurin May 12, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants