Skip to content

fix: handle empty YAML config files gracefully#440

Open
AaronFeledy wants to merge 1 commit intomainfrom
fix/empty-config-crash
Open

fix: handle empty YAML config files gracefully#440
AaronFeledy wants to merge 1 commit intomainfrom
fix/empty-config-crash

Conversation

@AaronFeledy
Copy link
Member

@AaronFeledy AaronFeledy commented Feb 25, 2026

Summary

When ~/.lando/config.yml is completely empty (no {}), yaml.load() returns undefined instead of an object. This causes a TypeError: Cannot read properties of undefined (reading 'pluginDirs') crash.

Fix

Add || {} fallback after every yaml.load() call that reads config files:

  • utils/load-config-files.js — main config source loading
  • lib/cli.js — CLI config reading
  • lib/lando.js — landofile loading

Testing

  1. Empty your config: echo '' > ~/.lando/config.yml
  2. Run any lando command
  3. Before: TypeError crash. After: works normally.

Fixes #439
Fixes lando/lando#3379


Note

Low Risk
Small defensive change that only affects config-loading edge cases; main risk is silently accepting unintended empty/invalid config content.

Overview
Prevents crashes when config YAML files are present but empty by treating yaml.load(...) returning undefined as {}.

This adds || {} fallbacks when loading user ~/.lando/config.yml, app Landofiles, and config sources in load-config-files, and records the fix in CHANGELOG.md (fixes #439).

Written by Cursor Bugbot for commit 5c2666c. This will update automatically on new commits. Configure here.

@netlify
Copy link

netlify bot commented Feb 25, 2026

Deploy Preview for lando-core ready!

Name Link
🔨 Latest commit 5c2666c
🔍 Latest deploy log https://app.netlify.com/projects/lando-core/deploys/699e807fab17ef00080f9fe5
😎 Deploy Preview https://deploy-preview-440--lando-core.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 84 (🟢 up 4 from production)
Accessibility: 89 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

When a YAML file (e.g. ~/.lando/config.yml) is completely empty,
yaml.load() returns undefined instead of an object. This causes a
TypeError when accessing properties like pluginDirs.

Default to an empty object when yaml.load() returns a falsy value
across all config loading paths.

Fixes #439
@AaronFeledy AaronFeledy force-pushed the fix/empty-config-crash branch from 5cc0d6a to 5c2666c Compare February 25, 2026 04:54
AaronFeledy added a commit to lando/core-next that referenced this pull request Feb 25, 2026
When a YAML file (e.g. ~/.lando/config.yml) is completely empty,
yaml.load() returns undefined instead of an object. This causes a
TypeError when accessing properties like pluginDirs.

Default to an empty object when yaml.load() returns a falsy value
across all config loading paths.

Backport of lando/core#440
Fixes lando/core#439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant