Skip to content

Avoid NPE when missing DTSTART for recurring events #1336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 16, 2025

Conversation

ArnyminerZ
Copy link
Member

@ArnyminerZ ArnyminerZ commented Mar 7, 2025

Purpose

Fixes #1265 by correctly handling situations where dtstart is null.

Short description

Handled nullability of DTSTART of recurring instances by setting the local value to null, which would re-create the local instance.

Stop querying VTODO (or VEVENT) recurrence instances with DTSTART, now using their UID and RECURRENCE-ID only.

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@ArnyminerZ ArnyminerZ added the bug Something isn't working label Mar 7, 2025
@ArnyminerZ ArnyminerZ requested review from rfc2822 and sunkup March 7, 2025 06:59
@ArnyminerZ ArnyminerZ self-assigned this Mar 7, 2025
@ArnyminerZ ArnyminerZ linked an issue Mar 7, 2025 that may be closed by this pull request
@ArnyminerZ
Copy link
Member Author

I've also added a log message so that if we find some data missing we can know what is it all about. If you don't find it necessary we can remove it.

@ArnyminerZ ArnyminerZ marked this pull request as ready for review March 7, 2025 06:59
@rfc2822 rfc2822 removed their request for review March 7, 2025 13:22
@rfc2822
Copy link
Member

rfc2822 commented Mar 7, 2025

Handled nullability of DTSTART of recurring instances by setting the local value to null, which would re-create the local instance.

What would that mean in our case? Do I understand it correctly that

  • the main VTODO (without RECURRENCE-ID) is normally created/updated,
  • and what happens with the VTODO with RECURRENCE-ID;TZID=America/New_York:20250228T130000? It seems to be added instead of updated in the code – is it deleted before so that it doesn't add a new instance for every sync?

Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

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

How about adding a test to verify and document correct behaviour?

@ArnyminerZ
Copy link
Member Author

How about adding a test to verify and document correct behaviour?

I've been looking at how to test this properly, and if I am not wrong, that would mean creating a new test class just like SyncManagerTest, but for JtxSyncManager, and checking whether it can handle those cases correctly right? @rfc2822 can correct me otherwise. I think it's actually a lot of code for just a "side-hustle".

Of course we can add it, but is it really worth it?

@sunkup
Copy link
Member

sunkup commented Mar 11, 2025

Of course we can add it, but is it really worth it?

I'd say yes definetly - If the test is relevant we should add it and in this case I find it highly relevant to properly understand (#1336 (comment)), clamp and document the newly added behaviour.

@rfc2822
Copy link
Member

rfc2822 commented Mar 11, 2025

At least we have a specific iCalendar we could test with… it's surely at least worth the try. If it's absolutely too cumbersome we can still cancel it then

What would that mean #1265 (comment)? Do I understand it correctly that

  • the main VTODO (without RECURRENCE-ID) is normally created/updated,
  • and what happens with the VTODO with RECURRENCE-ID;TZID=America/New_York:20250228T130000? It seems to be added instead of updated in the code – is it deleted before so that it doesn't add a new instance for every sync?

Did you already had a look at that?

Signed-off-by: Arnau Mora <[email protected]>
@rfc2822 rfc2822 requested a review from sunkup April 7, 2025 07:48
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

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

Not sure what you are trying to test here.

We should unit test processICalObject.

Testing for a recurrence with missing DTSTART should fail when the test is run with the old implementation (because NPE is thrown) and should succeed with the new implementation (the log statement shows).

Furthermore it would be good to have tests documenting/clamping the accompanying behaviour Ricki mentions.

EDIT:

Ah my bad. I think the PR is still work in progress and not ready for review yet @rfc2822

I will set it to draft again.

@sunkup sunkup marked this pull request as draft April 7, 2025 12:13
@sunkup sunkup self-assigned this Apr 8, 2025
@sunkup sunkup changed the title Added handling of null DTSTART of recurring instances Avoid NPE when missing DTSTART for recurring events Apr 8, 2025
sunkup added 2 commits April 8, 2025 13:02
Signed-off-by: Sunik Kupfer <[email protected]>
@sunkup
Copy link
Member

sunkup commented Apr 14, 2025

Added two tests now. The second one checks that, for a recurring vtodo with exception, but missing dtstart:

  • the main vtodo is added with its RRULE
  • the exception vtodo from the non-calculated RRULE (because the main vtodo has no DTSTART) is being added with its recurrence ID and timezone

For the tests to run successfully on CI we will need to install jtxBoard before running tests. Would it be very hard to setup a gradle task which downloads and installs the latest jtxboard version before the tests run?

@sunkup sunkup requested a review from rfc2822 April 14, 2025 08:52
@sunkup
Copy link
Member

sunkup commented Apr 14, 2025

Gradle task for installing jtxBoard automatically not possible yet. For now: Add assume statement before grant permission rule, so tests only run locally and are skipped in CI.

@sunkup sunkup removed the request for review from rfc2822 April 14, 2025 09:41
@sunkup sunkup requested a review from rfc2822 April 14, 2025 11:47
@sunkup sunkup marked this pull request as ready for review April 14, 2025 11:47
sunkup added 3 commits April 14, 2025 15:34
Signed-off-by: Sunik Kupfer <[email protected]>
Signed-off-by: Sunik Kupfer <[email protected]>
Signed-off-by: Sunik Kupfer <[email protected]>
@sunkup sunkup requested a review from rfc2822 April 15, 2025 10:38
@rfc2822
Copy link
Member

rfc2822 commented Apr 15, 2025

There's still a conflict

@sunkup
Copy link
Member

sunkup commented Apr 15, 2025

Ah, sorry about that. Fixed

@sunkup sunkup requested a review from rfc2822 April 16, 2025 10:43
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

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

Nice that it works with the CaptureExceptionsRule :)

sunkup added 3 commits April 16, 2025 14:03
Signed-off-by: Sunik Kupfer <[email protected]>
Signed-off-by: Sunik Kupfer <[email protected]>
@sunkup sunkup requested a review from rfc2822 April 16, 2025 12:09
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

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

:)

@rfc2822 rfc2822 merged commit 0d2e5a1 into main-ose Apr 16, 2025
8 checks passed
@rfc2822 rfc2822 deleted the 1265-jtx-board-task-sync-causes-nullpointerexception branch April 16, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[jtx Board] Task sync causes NullPointerException
3 participants