fix(dav): Handle GenericFileException when reading default contact file#61485
Open
kesselb wants to merge 2 commits into
Open
fix(dav): Handle GenericFileException when reading default contact file#61485kesselb wants to merge 2 commits into
kesselb wants to merge 2 commits into
Conversation
Assisted-by: ClaudeCode:claude-sonnet-4-6 Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Contributor
Author
|
/backport to stable34 |
Contributor
Author
|
/backport to stable33 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves robustness of DAV example content downloads by handling file read failures (notably GenericFileException) when loading stored default contact/event files, avoiding user-facing 500 errors and falling back to bundled defaults where appropriate.
Changes:
- Catch
GenericFileExceptionwhen reading a stored default contact vCard and returnnull(allowing controller fallback). - Catch
GenericFileExceptionwhen reading a custom example event ICS and rethrow asExampleEventException. - Add/extend unit tests covering these new error-handling paths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/dav/lib/Service/ExampleEventService.php | Extend custom event file read exception handling to include GenericFileException. |
| apps/dav/lib/Service/ExampleContactService.php | Wrap default contact file read in try/catch and log on GenericFileException, returning null for fallback behavior. |
| apps/dav/tests/unit/Service/ExampleEventServiceTest.php | Add unit coverage for custom event read failure via GenericFileException. |
| apps/dav/tests/unit/Service/ExampleContactServiceTest.php | Add unit coverage for missing folder/file and read errors when fetching the default contact. |
Comments suppressed due to low confidence (1)
apps/dav/lib/Service/ExampleEventService.php:114
ISimpleFile::getContent()can also throwOCP\Lock\LockedException(per interface) but it is not caught here. That means downloading/using a custom example event can still result in an uncaught exception and a 500, despite the method docblock stating it throwsExampleEventExceptionwhen reading fails.
try {
return $icsFile->getContent();
} catch (NotFoundException|NotPermittedException|GenericFileException $e) {
throw new ExampleEventException(
'Failed to read custom example event',
0,
$e,
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+51
to
58
| try { | ||
| return $folder->getFile('defaultContact.vcf')->getContent(); | ||
| } catch (NotFoundException $e) { | ||
| return null; | ||
| } catch (GenericFileException $e) { | ||
| $this->logger->error('Could not read default contact file', ['exception' => $e]); | ||
| return null; | ||
| } |
ChristophWurst
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
How to test:
Main: 500er page when downloading the default event
Here: Default event is downloaded
Checklist
3. to review, feature component)stable32)AI (if applicable)