Skip to content

Frequency rules without a BYDAY throw an error incorrectly #2427

@jaysignorello

Description

@jaysignorello

Bug description

Reopening #2237 for reconsideration. I also ran into this issue after pulling in .ics file pulled from Google Calendar. Google exports the RRULE exactly to specs as the previous bug explained.

FREQ=DAILY;INTERVAL=2 is a valid rule for example and a common way for Google to generate their iCalendar files

Per the specs (https://www.rfc-editor.org/rfc/rfc5545)

Information, not contained in the rule, necessary to determine the
      various recurrence instance start time and dates are derived from
      the Start Time ("DTSTART") component attribute.  For example,
      "FREQ=YEARLY;BYMONTH=1" doesn't specify a specific day within the
      month or a time.  This information would be the same as what is
      specified for "DTSTART".

In other words, BYDAY is derived from DTSTART when not present in the in the rule.

So while the Google UI requires a user to select a day, it doesn't mean it will be translated into the rule with BYDAY included.

Bug description

An rrule like this which is valid: FREQ=WEEKLY;UNTIL=20170324T220000Z;INTERVAL=2 throws an error because _findWeeklyRule (line 1754 of recurrence_helper.dart) return 0 items due to the if (weeklyRule[i].contains('BYDAY'))

According to the iCal spec the above is valid: https://www.kanzaki.com/docs/ical/rrule.html

Steps to reproduce

  1. Create an Appointment object with a valid weekly rrule that does not contain a BYDAY section
  2. Add it to a datasource of a calendar.

Code sample

Code sample

return SfCalendar(dataSource: source);

Screenshots or Video

Screenshots / Video demonstration

n/a

Stack Traces

On which target platforms have you observed this bug?

macOS

Flutter Doctor output

Steps to reproduce

  1. Create an Appointment object with a valid weekly rrule that does not contain a BYDAY section
  2. Add it to a datasource of a calendar.

Code sample

Code sample

return SfCalendar(dataSource: source);

Screenshots or Video

n/a

Stack Traces

Stack Traces
The following assertion was thrown building LayoutBuilder:
Invalid weekly recurrence rule
'package:syncfusion_flutter_calendar/src/calendar/appointment_engine/recurrence_helper.dart':
Failed assertion: line 271 pos 12: 'weeklyByDayPos != -1'

The relevant error-causing widget was: 
  SfCalendar SfCalendar:file:///Users/chanan/flutter/bkhome/lib/features/calendar/widgets/calendar_widget.dart:30:12
When the exception was thrown, this was the stack: 
#2      RecurrenceHelper._getWeeklyRecurrenceDateTimeCollection (package:syncfusion_flutter_calendar/src/calendar/appointment_engine/recurrence_helper.dart:271:12)
#3      RecurrenceHelper.getRecurrenceDateTimeCollection (package:syncfusion_flutter_calendar/src/calendar/appointment_engine/recurrence_helper.dart:1072:14)
#4      _SfCalendarState._getMaxAppointmentDate (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:5273:28)
#5      _SfCalendarState.addAgenda (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:6722:16)
#6      _SfCalendarState.build.<anonymous closure> (package:syncfusion_flutter_calendar/src/calendar/sfcalendar.dart:3100:21)
#7      _LayoutBuilderElement._rebuildWithConstraints.updateChildCallback (package:flutter/src/widgets/layout_builder.dart:199:77)
#8      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3038:19)
#9      _LayoutBuilderElement._rebuildWithConstraints (package:flutter/src/widgets/layout_builder.dart:239:12)
#10     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2738:59)
#11     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1108:15)
#12     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2738:14)
#13     RenderConstrainedLayoutBuilder.rebuildIfNecessary (package:flutter/src/widgets/layout_builder.dart:286:5)
#14     _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:377:5)
#15     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2465:7)
#16     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1062:18)
#17     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1075:15)
#18     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:609:23)
#19     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1178:13)
#20     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:475:5)
#21     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397:15)
#22     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1318:9)
#23     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1176:5)
#24     _invoke (dart:ui/hooks.dart:312:13)
#25     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:427:5)
#26     _drawFrame (dart:ui/hooks.dart:283:31)
(elided 2 frames from class _AssertionError)

On which target platforms have you observed this bug?

iOS, Android, Web

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.2 24C101 darwin-arm64, locale en-US)
• Flutter version 3.27.1 on channel stable at /Users/chanan/flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 17025dd882 (2 weeks ago), 2024-12-17 03:23:09 +0900
• Engine revision cb4b5fff73
• Dart version 3.6.0
• DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/chanan/Library/Android/sdk
• Platform android-35, build-tools 34.0.0
• ANDROID_HOME = /Users/chanan/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.14.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] VS Code (version 1.96.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.102.0

[✓] Connected device (5 available)
• Chanan’s iPhone (mobile) • 00008140-001201C12EA3001C • ios • iOS 18.3 22D5034e
• macOS (desktop) • macos • darwin-arm64 • macOS 15.2 24C101 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.2 24C101 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 131.0.6778.205
• Raspberry Pi 5 (mobile) • pi-5 • linux-arm64 • Raspberry Pi 5
! Error: Browsing on the local area network for Chanan’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
• All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    calendarCalendar componentsolvedSolved the query using existing solutionswaiting for customer responseCannot make further progress until the customer responds.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions