fix: handle empty YAML config files gracefully#440
Open
AaronFeledy wants to merge 1 commit intomainfrom
Open
Conversation
✅ Deploy Preview for lando-core ready!
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
5cc0d6a to
5c2666c
Compare
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
When
~/.lando/config.ymlis completely empty (no{}),yaml.load()returnsundefinedinstead of an object. This causes aTypeError: Cannot read properties of undefined (reading 'pluginDirs')crash.Fix
Add
|| {}fallback after everyyaml.load()call that reads config files:utils/load-config-files.js— main config source loadinglib/cli.js— CLI config readinglib/lando.js— landofile loadingTesting
echo '' > ~/.lando/config.ymllandocommandFixes #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(...)returningundefinedas{}.This adds
|| {}fallbacks when loading user~/.lando/config.yml, app Landofiles, and config sources inload-config-files, and records the fix inCHANGELOG.md(fixes #439).Written by Cursor Bugbot for commit 5c2666c. This will update automatically on new commits. Configure here.