Skip to content

catch errors when parsing calendar data for calendar query requests#6901

Merged
MorrisJobke merged 1 commit intomasterfrom
bugfix/4014/catch_parsing_error
Nov 27, 2017
Merged

catch errors when parsing calendar data for calendar query requests#6901
MorrisJobke merged 1 commit intomasterfrom
bugfix/4014/catch_parsing_error

Conversation

@georgehrke
Copy link
Copy Markdown
Member

fixes #4014

@georgehrke georgehrke added the 3. to review Waiting for reviews label Oct 22, 2017
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 22, 2017

Codecov Report

Merging #6901 into master will decrease coverage by <.01%.
The diff coverage is 26.31%.

@@             Coverage Diff              @@
##             master    #6901      +/-   ##
============================================
- Coverage     50.86%   50.85%   -0.01%     
- Complexity    24534    24538       +4     
============================================
  Files          1584     1584              
  Lines         93778    93803      +25     
  Branches       1358     1358              
============================================
+ Hits          47696    47705       +9     
- Misses        46082    46098      +16
Impacted Files Coverage Δ Complexity Δ
apps/dav/appinfo/v1/caldav.php 0% <0%> (ø) 0 <0> (ø) ⬇️
apps/dav/lib/Command/CreateCalendar.php 50% <0%> (-1.86%) 4 <0> (ø)
apps/dav/lib/RootCollection.php 92.85% <100%> (+0.1%) 1 <0> (ø) ⬇️
apps/dav/lib/CalDAV/CalDavBackend.php 84.21% <23.07%> (-0.78%) 244 <0> (+2)
.../dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php 51.72% <0%> (-27.23%) 8% <0%> (+2%)
core/js/js.js 63.55% <0%> (+0.56%) 0% <0%> (ø) ⬇️
lib/private/Files/Cache/Propagator.php 96.2% <0%> (+1.26%) 16% <0%> (ø) ⬇️

// catch parsing errors
try {
$matches = $this->validateFilterForObject($row, $filters);
} catch(\Exception $ex) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe catch only Sabre\VObject\ParseException ? Since it can also throw Sabre\DAV\Exception\NotImplemented and Sabre\DAV\Exception\BadRequest (inside Sabre\DAV\CalendarQueryValidator) which shouldn't be logged as an error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was considering, but sadly it's not very well documented (at least i didn't find something), what exceptions can be thrown. In the bug report it was InvalidDataException.
And the pity is, that there is no real hierarchy but all inherit from \Exception

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You could check against the known (base) classes and if it's an unkown once you just re-throw it.

$matches = $this->validateFilterForObject($row, $filters);
} catch(\Exception $ex) {
$this->logger->error('Catched parsing exception for calendar data. This indicates invalid calendar data. URI:' . $row['uri']);
$this->logger->logException($ex);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please combine those two:

$this->logger->logException($ex, [
'app' => 'dav',
'message' => 'Catched parsing exception for calendar data. This indicates invalid calendar data. URI:' . $row['uri'],
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And use caught instead 😉

@georgehrke georgehrke force-pushed the bugfix/4014/catch_parsing_error branch 2 times, most recently from 172eb88 to 1b9dfa3 Compare November 1, 2017 16:01
@georgehrke
Copy link
Copy Markdown
Member Author

done

@georgehrke georgehrke self-assigned this Nov 7, 2017
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
@MorrisJobke MorrisJobke force-pushed the bugfix/4014/catch_parsing_error branch from 1b9dfa3 to ea117ba Compare November 27, 2017 16:14
@MorrisJobke
Copy link
Copy Markdown
Member

Fixed merge conflict in use imports in one file.

@MorrisJobke MorrisJobke added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Nov 27, 2017
@MorrisJobke MorrisJobke added this to the Nextcloud 13 milestone Nov 27, 2017
@MorrisJobke MorrisJobke merged commit 3f7267e into master Nov 27, 2017
@MorrisJobke MorrisJobke deleted the bugfix/4014/catch_parsing_error branch November 27, 2017 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

500 error, don´t know what it means

5 participants