Transformation YAML Reference Alpha

Complete YAML reference for transformation and transformation-library resources managed with Rudder CLI.
Available Plans
  • free
  • starter
  • growth
  • enterprise

This guide provides a complete YAML reference for managing transformation resources using Rudder CLI.

Overview

You can define transformation resources in YAML files anywhere inside your CLI project directory. Rudder CLI scans the project recursively and processes valid resource files.

Supported resource kinds for this workflow:

  • transformation
  • transformation-library

Transformation resource

Use kind: transformation to define a transformation.

spec properties

PropertyType
Description
id
Required
StringUnique project ID for the transformation.
name
Required
StringHuman-readable name. Must be non-empty.
language
Required
StringTransformation language. Allowed values: javascript, python.
descriptionStringOptional description.
codeStringInline transformation code containing valid syntax for the selected language. Mutually exclusive with file.
fileStringPath to transformation code file. Note that:

  • The referenced file must exist and be readable.
  • Relative paths are resolved from the YAML spec’s parent directory.
warning
One of code or file is required.
testsArrayOptional list of local test suites. These tests are used only by rudder-cli transformations test and are not synced to workspace state during rudder-cli apply.

tests properties

PropertyType
Description
name
Required
StringTest suite name. Must be non-empty and can contain only letters, numbers, spaces, _, -, and /.
inputStringDirectory with JSON input payload files. Relative paths resolve from the spec directory. If omitted, default is ./input.
outputStringDirectory with expected output JSON files. Relative paths resolve from the spec directory. If omitted, default is ./output.
info

Rudder CLI tests the transformation using default RudderStack events if:

  • spec.tests is not configured, or
  • No input JSON files are found in the specified input path

Transformation library resource

Use kind: transformation-library to define a reusable transformation library.

spec properties

PropertyType
Description
id
Required
StringUnique project ID for the library.
name
Required
StringHuman-readable name — must be non-empty.
descriptionStringOptional description.
language
Required
StringLibrary language. Allowed values are javascript and python.
codeStringInline library code containing valid syntax for the selected language. Mutually exclusive with file.
fileStringPath to library code file. Note that:

  • The referenced file must exist and be readable.
  • Relative paths are resolved from the YAML spec’s parent directory.
warning
One of code or file is required.
import_name
Required
StringHandle used when importing the library in transformation code — must be camelCase of name.

warning
Validation fails if import_name does not match the camelCase form of name.

Testing framework

Rudder CLI includes a rich built-in testing framework for validating transformations and transformation libraries locally.

Structure

The testing framework uses input and output directories to run test cases:

  • All files in the input directory are treated as test inputs
  • Corresponding files in the output directory are used as expected outputs for comparison against the actual transformation results
warning
Input and output file names must match for accurate testing and comparison.

For each test case, the framework sends the input event through the transformation and compares the actual output against the expected output.

Test modes

The testing framework supports two modes:

ModeDescription
DefaultDisplays minimal details about test results.
--verboseDisplays more context around differences, including three lines above and below each code diff.

Test result classification

Each input file represents a separate test case. Rudder CLI classifies transformation test results into the following categories:

ResultDescription
PassedThe actual output matches the expected output. If the expected output is missing, then a successful execution is considered as passed.
Execution errorThe transformation code encountered an error during execution.
Output mismatch errorThe actual output doesn’t match the expected output.
info
Transformation library tests focus specifically on syntax validation.

See more


Questions? Contact us by Email or on Slack