Skip to content

Fix calendar crash when yearmatchgroup regex does not match - #4238

Closed
Antra wants to merge 2 commits into
MagicMirrorOrg:developfrom
Antra:calendar-custom-event-fixes
Closed

Fix calendar crash when yearmatchgroup regex does not match#4238
Antra wants to merge 2 commits into
MagicMirrorOrg:developfrom
Antra:calendar-custom-event-fixes

Conversation

@Antra

@Antra Antra commented Aug 29, 2026

Copy link
Copy Markdown

Description

Fixes an issue in CalendarUtils.titleTransform() when a title transformation uses yearmatchgroup but the configured regular expression does not match the event title.

Currently, matchAll() returns an empty array when there is no match, but the code subsequently accesses yearmatch[0].length. This results in an exception and causes the calendar module to stop displaying its events.

This can occur when using yearmatchgroup for birthday events, for example, when some matching events have a birth year in the expected format while another event matching the keyword does not.

Change

Check that yearmatch contains at least one match before accessing yearmatch[0].

This is a one-line change and leaves the existing behaviour unchanged when the regular expression matches.

Example

With a transformation such as:

transform: {
    search: "^(.+) \\((\\d{4})\\)$",
    replace: "$1 ($2)",
    yearmatchgroup: 2
}

an event such as:

Test Birthday (1987)

continues to be transformed to:

Test Birthday (39)

while an event matching the custom-event keyword but not the year pattern no longer causes the calendar module to fail.

rejas and others added 2 commits July 1, 2026 22:01
## Release Notes
Thanks to: @angeldeejay, @egeekial, @khassel, @KristjanESPERANTO,
@MikeBishop, @rejas
> ⚠️ This release needs nodejs version >=22.21.1 <23 || >=24 (no change
to previous release)

[Compare to previous Release
v2.36.0](MagicMirrorOrg/MagicMirror@v2.36.0...develop)


### [core]
- Prepare Release 2.37.0 (MagicMirrorOrg#4193)
- fix(electron): map IPv6 :: wildcard to localhost (MagicMirrorOrg#4188)
- refactor(main): modernize DOM update flow with async/await (MagicMirrorOrg#4186)
- refactor(main): simplify _updateDom with async/await (MagicMirrorOrg#4185)
- fix(security): prevent unauthorized secret expansion in socket
payloads (MagicMirrorOrg#4184)
- refactor(main): simplify updateDomWithContent async flow (MagicMirrorOrg#4182)
- fix: modules losing data after HTTP 304 responses (MagicMirrorOrg#4180)
- chore: add missing core defaults (MagicMirrorOrg#4181)
- fix(server): enforce ipWhitelist for Socket.IO too (MagicMirrorOrg#4169)
- feat(systeminfo): include Git hash and branch in system information
log (MagicMirrorOrg#4167)
- feat(electron): support object-based electronSwitches (MagicMirrorOrg#4161)
- systeminformation thread not ending: move error handling from utils to
app (MagicMirrorOrg#4160)
- fix systeminformation thread not ending (MagicMirrorOrg#4155)
- refactor: use ES module imports in browser core (MagicMirrorOrg#4158)
- refactor(core): remove old Object.assign polyfill (MagicMirrorOrg#4157)
- refactor: rewrite Module as an ES6 class (MagicMirrorOrg#4151)
- refactor: rewrite NodeHelper as an ES6 class (MagicMirrorOrg#4147)
- update eletron to v42 (MagicMirrorOrg#4144)
- refactor(utils): drop ajv dependency (MagicMirrorOrg#4142)
- fix(systeminformation): output right 'used node' version (from parent
process) (MagicMirrorOrg#4141)
- fix: skip postinstall git clean when not in a git repository (MagicMirrorOrg#4139)
- Remove unnecessary conditionals and fix falsy property check in
imperial conversion (MagicMirrorOrg#4135)
- update version in package.json

### [dependencies]
- update dependencies (MagicMirrorOrg#4191)
- Bump actions/checkout from 6 to 7 (MagicMirrorOrg#4190)
- chore: update dependencies and adjust import path for SunCalc (MagicMirrorOrg#4189)
- update dependencies incl. electron and revert
yauzl-electron-install-fix (MagicMirrorOrg#4183)
- update dependencies, add electron fix in package.json (MagicMirrorOrg#4175)
- chore: update dependencies (MagicMirrorOrg#4162)
- Bump actions/dependency-review-action from 4 to 5 (MagicMirrorOrg#4152)
- Unify linting: replace Stylelint and markdownlint with ESLint (MagicMirrorOrg#4148)
- update dependencies and workflows to node v26 (MagicMirrorOrg#4140)

### [modules/alert]
- CodeQL cleanup for alerts MagicMirrorOrg#18, MagicMirrorOrg#19, MagicMirrorOrg#20 (MagicMirrorOrg#4153)
- fix: resolve CodeQL alerts MagicMirrorOrg#24 and MagicMirrorOrg#26 (MagicMirrorOrg#4145)
- fix(electron): resolve CodeQL alerts MagicMirrorOrg#22 and MagicMirrorOrg#25 in electron.js
(MagicMirrorOrg#4136)

### [modules/calendar]
- perf(calendar): pre-filter ICS data before parsing (MagicMirrorOrg#4168)
- perf(calendar): use async ICS parsing to avoid blocking event loop
(MagicMirrorOrg#4143)

### [modules/newsfeed]
- [newsfeed] add allowBasicHtmlTags option for basic emphasis (MagicMirrorOrg#4176)

### [modules/updatenotification]
- fix(updatenotification): don't spawn a child process when running
under PM2 (MagicMirrorOrg#4166)
- fix(updatenotification): use process.argv[0] as restart binary (MagicMirrorOrg#4163)
- fix(updatenotification): preserve start mode on restart (MagicMirrorOrg#4156)
- fix(updatenotification): fix ref diff parsing for fetch --dry-run
(MagicMirrorOrg#4138)
- refactor(updatenotification): replace pm2 usage with node logic
(MagicMirrorOrg#4134)

### [modules/weather]
- feat(weather): add Buienradar provider (MagicMirrorOrg#4164)

### [testing]
- remove warning in unit tests (for nodejs >= v25) (MagicMirrorOrg#4149)
- polish HTTP 304 docs/test/handling (MagicMirrorOrg#4129)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: BugHaver <43462320+bughaver@users.noreply.github.com>
Co-authored-by: BugHaver <43462320+lsaadeh@users.noreply.github.com>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com>
Co-authored-by: Koen Konst <koenspero@gmail.com>
Co-authored-by: Koen Konst <c.h.konst@avisi.nl>
Co-authored-by: Bugsounet - Cédric <github@bugsounet.fr>
Co-authored-by: dathbe <github@beffa.us>
Co-authored-by: veeck <gitkraken@veeck.de>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcel <m-idler@users.noreply.github.com>
Co-authored-by: sam detweiler <sdetweil@gmail.com>
Co-authored-by: Kevin G. <crazylegstoo@gmail.com>
Co-authored-by: Jboucly <33218155+jboucly@users.noreply.github.com>
Co-authored-by: Jboucly <contact@jboucly.fr>
Co-authored-by: Jarno <54169345+jarnoml@users.noreply.github.com>
Co-authored-by: Jordan Welch <JordanHWelch@gmail.com>
Co-authored-by: Blackspirits <blackspirits@gmail.com>
Co-authored-by: Samed Ozdemir <samed@xsor.io>
Co-authored-by: in-voker <58696565+in-voker@users.noreply.github.com>
Co-authored-by: Andrés Vanegas Jiménez <142350+angeldeejay@users.noreply.github.com>
Co-authored-by: cgillinger <christian.gillinger@gmail.com>
Co-authored-by: Sonny B <43247590+sonnyb9@users.noreply.github.com>
Co-authored-by: sonnyb9 <sonnyb9@users.noreply.github.com>
Co-authored-by: Morgan McBee <egeekial@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Mike Bishop <mbishop@evequefou.be>
@Antra Antra closed this Aug 29, 2026
@Antra

Antra commented Aug 29, 2026

Copy link
Copy Markdown
Author

I think I messed that up as well.

@Antra

Antra commented Aug 29, 2026

Copy link
Copy Markdown
Author

Resubmitted as:
#4239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants