Skip to content

Conversation

@KristjanESPERANTO
Copy link
Collaborator

@KristjanESPERANTO KristjanESPERANTO commented Oct 22, 2025

  • Combine file existence and permission checks with better error messages
  • Replace thrown exceptions with clean error output (no stack traces)
  • Support custom module positions by changing strict validation to warnings
  • Add missing process.exit(1) after validation errors

Users now see clear, actionable error messages without stack traces, and custom region configurations work correctly.

example before

$ npm run start

> magicmirror@2.34.0-develop start
> node --run start:x11

[2025-10-22 17:56:06.303] [LOG]   Starting MagicMirror: v2.34.0-develop 
[2025-10-22 17:56:06.304] [LOG]   Loading config ... 
[2025-10-22 17:56:06.304] [LOG]   config template file not exists, no envsubst 
[2025-10-22 17:56:06.356] [ERROR] File not found: /home/kristjan/MagicMirror/config/config.js
No config file present! 
[2025-10-22 17:56:06.356] [ERROR] [checkconfig] Error: Error: ENOENT: no such file or directory, access '/home/kristjan/MagicMirror/config/config.js'
No permission to access config file!
    at checkConfigFile (/home/kristjan/MagicMirror/js/check_config.js:43:9)
    at Object.<anonymous> (/home/kristjan/MagicMirror/js/check_config.js:138:2)
    at Module._compile (node:internal/modules/cjs/loader:1714:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1848:10)
    at Module.load (node:internal/modules/cjs/loader:1448:32)
    at Module._load (node:internal/modules/cjs/loader:1270:12)
    at c._load (node:electron/js2c/node_init:2:17993)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
    at Module.require (node:internal/modules/cjs/loader:1470:12)
    at require (node:internal/modules/helpers:147:16)
    at loadConfig (/home/kristjan/MagicMirror/js/app.js:126:3)
    at App.start (/home/kristjan/MagicMirror/js/app.js:291:18)
    at Object.<anonymous> (/home/kristjan/MagicMirror/js/electron.js:228:7)
    at Module._compile (node:internal/modules/cjs/loader:1714:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1848:10) 

example after

$ npm run start

> magicmirror@2.34.0-develop start
> node --run start:x11

[2025-10-22 21:33:27.930] [LOG]   Starting MagicMirror: v2.34.0-develop 
[2025-10-22 21:33:27.931] [LOG]   Loading config ... 
[2025-10-22 21:33:27.931] [LOG]   config template file not exists, no envsubst 
[2025-10-22 21:33:27.985] [ERROR] [check_config] File not found: /home/kristjan/MagicMirror/config/config.js 

@KristjanESPERANTO KristjanESPERANTO marked this pull request as draft October 22, 2025 19:47
@rejas
Copy link
Collaborator

rejas commented Oct 22, 2025

Users now see clearer, actionable error messages instead of unnecessary technical output (stack trace) when their config file has issues.

nice pr, but could we have an option that enables the stacktraces again (so one can still get them when needed)

maybe a command line param to enable it, since if it was a config.js option it might not work when check_config fails for some reason (since the config wouldnt have been loaded)

- Combine file existence and permission checks with better error messages
- Replace thrown exceptions with clean error output (no stack traces)
- Support custom module positions by changing strict validation to warnings
- Add consistent [check_config] prefix to all log messages
- Add missing process.exit(1) after validation errors

Users now see clear, actionable error messages without stack traces, and
custom region configurations work correctly.
@KristjanESPERANTO KristjanESPERANTO changed the title [check_config] refactor: improve error handling and user experience [check_config] refactor: improve error handling Oct 22, 2025
@KristjanESPERANTO
Copy link
Collaborator Author

nice pr, but could we have an option that enables the stacktraces again (so one can still get them when needed)

The stack traces are only removed for 'expected' validation errors (file not found, syntax error, invalid position) - with showing clean error messages there is no need of the stack trace, I think. The stack traces weren't providing useful debugging information, they just showed where we intentionally check for these errors.

For unexpected errors, there will be stack traces also after this change (the catch block at the bottom still logs them).

Should I nevertheless add a parameter?

@KristjanESPERANTO KristjanESPERANTO marked this pull request as ready for review October 22, 2025 21:30
@rejas rejas merged commit 9ad5618 into MagicMirrorOrg:develop Oct 23, 2025
9 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the config branch October 26, 2025 14:16
@sdetweil sdetweil mentioned this pull request Jan 1, 2026
sdetweil added a commit that referenced this pull request Jan 1, 2026
Thanks to: @Blackspirits, @Crazylegstoo, @jarnoml, @jboucly, @JHWelch,
@khassel, @KristjanESPERANTO, @rejas, @sdetweil, @xsorifc28

⚠️ This release needs nodejs version >=22.21.1 <23 || >=24

[Compare to previous Release
v2.33.0](v2.33.0...develop)

[core]
Prepare Release 2.34.0
(#3998)
dependency update + adjust Playwright setup + fix linter issue
(#3994)
demo with gif (#3995)
[core] fix: allow browser globals in config files
(#3992)
[core] fix: restore --ozone-platform=wayland flag for reliable Wayland
support (#3989)
[core] auto create release notes with every push on develop
(#3985)
[core] chore: simplify Wayland start script
(#3974)
[gitignore] restore the old Git behavior for the default modules
(#3968)
[core] configure cspell to check default modules only and fix typos
(#3955)
[gitignore] restoring the old Git behavior for the CSS directory
(#3954)
feat(core): add server:watch script with automatic restart on file
changes (#3920)
[check_config] refactor: improve error handling
(#3927)
refactor: replace express-ipfilter with lightweight custom middleware
(#3917)
refactor: replace module-alias dependency with internal alias resolver
(#3893)

[dependencies]

[chore] update dependencies and min. node version
(#3986)
[core] bump dependencies into december
(#3982)
Bump actions/checkout from 5 to 6
(#3972)
Update deps, unpin parse5
(#3934)
[core] Update deps and pin jsdom to v27.0.0
(#3925)
chore: update dependencies
(#3921)
update deps, exclude node v23
(#3916)
remove eslint warnings, add npm publish process to Collaboration.md
(#3913)
feat: add ESlint rule no-sparse-arrays for config check
(#3911)
chore: bump dependencies into october
(#3909)

[logging]

logger: add calling filename as prefix on server side
(#3926)
[logger] Add prefixes to most Log messages
(#3923)

[modules/alert]
Add new pt and pt-BR translations for Alert module and update global PT
strings (#3965)

[modules/calendar]
add checksum to test whether calendar event list changed
(#3988)
[calendar] fix: prevent excessive fetching on client reload and refactor
calendarfetcherutils.js
(#3976)
[calendar] refactor: migrate CalendarFetcher to ES6 class and improve
error handling (#3959)
[calendar] Show repeatingCountTitle only if yearDiff > 0
(#3949)
[tests] suppress debug logs in CI environment + improve calendar symbol
test stability (#3941)
[calendar] chore: remove requiresVersion: "2.1.0"
(#3932)
[calendar] test: remove "Recurring event per timezone" test
(#3929)

[modules/compliments]
[compliments] refactor: optimize loadComplimentFile method and add unit
tests (#3969)
fix: set compliments remote file minimum delay to 15 minutes
(#3970)
[compliments] fix: duplicate query param "?" in compliments module
refresh url (#3967)

[modules/newsfeed]
[newsfeed] fix header layout issue
(#3946)

[modules/weather]
[weatherprovider] update subclass language use override
(#3914)
[weather] fix wind-icon not showing in pirateweather
(#3957)
[weather] add error handling to weather fetch functions, including cors
(#3791)
remove deprecated ukmetoffice datapoint provider, cleanup .gitignore
(#3952)
fixes problems with daylight-saving-time in weather provider openmeteo
(#3931)
Fix for envcanada Provider to use updated Env Canada URL
(#3919)
[weather] feat: add configurable forecast date format option
(#3918)

[testing]
testing: update "Enforce Pull-Request Rules" workflow
(#3987)
[core] refactor: replace XMLHttpRequest with fetch and migrate e2e tests
to Playwright (#3950)
[test] replace node-libgpiod with serialport in electron-rebuild
workflow (#3945)
[ci] Add concurrency to automated tests workflow to cancel outdated runs
(#3943)
[tests] migrate from jest to vitest
(#3940)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: Ryan Williams <65094007+ryan-d-williams@users.noreply.github.com>
Co-authored-by: Veeck <github@veeck.de>
Co-authored-by: Bugsounet - Cédric <github@bugsounet.fr>
Co-authored-by: Marc Landis <dirk.rettschlag@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: HeikoGr <20295490+HeikoGr@users.noreply.github.com>
Co-authored-by: Pedro Lamas <pedrolamas@gmail.com>
Co-authored-by: veeck <gitkraken@veeck.de>
Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com>
Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com>
Co-authored-by: DevIncomin <56730075+Developer-Incoming@users.noreply.github.com>
Co-authored-by: Nathan <n8nyoung@gmail.com>
Co-authored-by: mixasgr <mixasgr@users.noreply.github.com>
Co-authored-by: Savvas Adamtziloglou <savvas-gr@greeklug.gr>
Co-authored-by: Konstantinos <geraki@gmail.com>
Co-authored-by: OWL4C <124401812+OWL4C@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: Koen Konst <koenspero@gmail.com>
Co-authored-by: Koen Konst <c.h.konst@avisi.nl>
Co-authored-by: dathbe <github@beffa.us>
Co-authored-by: Marcel <m-idler@users.noreply.github.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>
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.

3 participants