Overview
This node provides functionality to manipulate YAML data within n8n workflows. Specifically, the "Set value in YAML" operation allows users to modify existing YAML content by setting or updating specific fields with new values. This is useful when you want to programmatically update configuration files, templates, or any YAML-structured data during automation.
Common scenarios include:
- Updating configuration parameters in a YAML file before deploying infrastructure.
- Modifying nested YAML data structures dynamically based on workflow inputs.
- Injecting or overriding values in YAML-formatted data received from previous nodes.
For example, you might have a YAML document representing a Kubernetes deployment manifest and want to change the image tag or replica count dynamically.
Properties
| Name | Meaning |
|---|---|
| Input Yaml Field | The name of the property in the input JSON that contains the YAML data where values should be set. For example, if your YAML content is stored under data, specify "data". |
| Fields to Set | A collection of fields to modify or add in the YAML data. Each field includes: - Name: The path to the field using dot notation (e.g., person[0].name). - Type: The data type of the value (String, Number, Boolean, Array, Object). - Value: The actual value to set, matching the selected type. |
| Input Type | Specifies the format of the input data containing the YAML: - Binary - String - Auto detecting (default) |
| Binary Options | Options relevant if the input type is binary: - File Encoding: Character encoding of the binary file (default UTF-8). - Strip BOM: Whether to remove Byte Order Mark for certain encodings. - Keep Source: Whether to keep JSON, binary, or both data types from the input item. |
| Set Options | Additional options for setting values: - Ignore Type Conversion Errors: If enabled, the node will apply less strict type conversion and ignore errors related to mismatched types. |
Output
The output JSON contains the modified YAML data after applying the specified field updates. The structure mirrors the input but with updated values at the specified paths.
If the input was binary, the output can also include binary data depending on the "Keep Source" option.
No explicit binary output is generated by this operation itself; it primarily modifies YAML content represented as JSON or string.
Dependencies
- No external services or API keys are required.
- The node relies on internal YAML parsing and serialization libraries bundled with the node's implementation.
- Proper handling of character encoding is important when dealing with binary input.
Troubleshooting
- Incorrect field paths: Using invalid or non-existent dot notation paths in "Fields to Set" may cause the node to fail to update the intended value. Double-check the path syntax.
- Type mismatch errors: If the value type does not match the expected type (e.g., setting a string where a number is expected), the node may throw conversion errors unless "Ignore Type Conversion Errors" is enabled.
- Encoding issues: When input is binary, specifying the wrong file encoding can lead to parsing failures or corrupted output. Ensure the encoding matches the source file.
- Empty or malformed YAML input: Providing empty or invalid YAML content in the specified input field will cause parsing errors.
Links and References
- YAML Official Site
- YAML Specification
- n8n Documentation on Working with Binary Data
- Dot Notation Reference (for understanding field path syntax)