You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Garden crashes if a YAML anchor that's not defined is used. Here's an example config:
clusterBuildkit:
cache:
- type: registry
tag: _buildcache-main
registry: *cacheRegistry # <-- This is not defined anywhere
Error message
Encountered an unexpected Garden error. This is likely a bug :fallen_leaf:
You can help by reporting this on GitHub: https://github.com/garden-io/garden/issues/new?labels=bug,crash&template=CRASH.md&title=Crash%3A%20Unresolved%20alias%20(the%20anchor%20must%20be%20set%20before%20the%20alias)%3A%20cacheRegistry
Please attach the following information to the bug report after making sure that the error message does not contain sensitive information:
ReferenceError: Unresolved alias (the anchor must be set before the alias): cacheRegistry
at Alias.toJSON (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/Alias.js:42:19)
at Object.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/toJS.js:22:26)
at Object.addPairToJSMap (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/addPairToJSMap.js:32:34)
at YAMLMap.toJSON (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/YAMLMap.js:124:28)
at Object.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/toJS.js:22:26)
at YAMLSeq.toJSON (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/YAMLSeq.js:76:27)
at Object.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/toJS.js:22:26)
at Object.addPairToJSMap (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/addPairToJSMap.js:32:34)
at YAMLMap.toJSON (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/YAMLMap.js:124:28)
at Object.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/toJS.js:22:26)
at Object.addPairToJSMap (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/addPairToJSMap.js:32:34)
at YAMLMap.toJSON (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/YAMLMap.js:124:28)
at Object.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/toJS.js:22:26)
at Object.addPairToJSMap (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/addPairToJSMap.js:32:34)
at YAMLMap.toJSON (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/YAMLMap.js:124:28)
at Object.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/toJS.js:22:26)
at Object.addPairToJSMap (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/addPairToJSMap.js:32:34)
at YAMLMap.toJSON (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/YAMLMap.js:124:28)
at Object.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/nodes/toJS.js:22:26)
at Document.toJS (/<path-to>/garden-io/garden/core/node_modules/yaml/dist/doc/Document.js:301:26)
at prepareResource (/<path-to>/garden-io/garden/core/build/src/config/base.js:133:22)
at /<path-to>/garden-io/garden/core/build/src/config/base.js:114:16
What did you do?
Ran any Garden command.
Your environment
OS: macOS Monterey
Garden version: Latest main
Frequency
Always.
Workaround
Write correct YAML (it's not as easy as it sounds) :)
The text was updated successfully, but these errors were encountered:
The issue is that we only catch errors in loadAndValidateYaml , but apparently with the new YAML parsing library for improved error messages (which is awesome btw!) seems to throw when calling toJS() on the YAML document as well (happens in prepareResource).
We likely should call toJS in loadAndValidateYaml as well and convert it to ConfigurationError.
I think this actually might be a bug in the yaml library; I created an issue upstream: eemeli/yaml#497
stefreak
changed the title
Crash: Unresolved alias (the anchor must be set before the alias): cacheRegistry
Crash: Unresolved alias (the anchor must be set before the alias)
Oct 9, 2023
* chore(deps): update yaml to 2.3.2
* fix: prevent crash due to unresolved alias in yaml
Fixes#5186
* improvement: use loadAndValidateYaml for both kubernetes manifests and
garden configs
test: add tests for loadAndValidateYaml
* improvement: eliminate explicit any in loadAndValidateYaml
Crash report
Garden crashes if a YAML anchor that's not defined is used. Here's an example config:
Error message
What did you do?
Ran any Garden command.
Your environment
Frequency
Always.
Workaround
Write correct YAML (it's not as easy as it sounds) :)
The text was updated successfully, but these errors were encountered: