fix: handle empty YAML config files gracefully#132
Open
AaronFeledy wants to merge 1 commit intomainfrom
Open
Conversation
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
❌ Deploy Preview for lando-core-next failed. Why did it fail? →
|
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
Backport of lando/core#440.
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 loadingNote
Low Risk
Small, localized defensive change that only affects how empty YAML files are interpreted; low chance of behavior change beyond avoiding a crash.
Overview
Prevents a crash when a config YAML file exists but is empty (so
yaml.load()returnsundefined) by defaulting all relevant loads to{}.This updates config reading/merging in
utils/load-config-files.js,Cli.updateUserConfig()(~/.lando/config.yml), andLando.getApp()landofile loading to tolerate empty files, and records the fix inCHANGELOG.md(lando/core#439).Written by Cursor Bugbot for commit 579bb5f. This will update automatically on new commits. Configure here.