CircleCI Generated Config Invalid - Fix Dynamic Config Output
The config your setup stage generated does not compile. A templating script emitted malformed YAML, dropped the version line, or path filtering produced an empty/invalid file that CircleCI cannot turn into a pipeline.
What this error means
The setup stage runs your generator, but compilation of the produced file fails with a YAML or schema error. The dynamic jobs never run because the second config is not a valid CircleCI config.
Config compilation failed for generated config:
Unable to parse YAML: did not find expected key
in '.circleci/generated.yml', line 7, column 3Common causes
Templating produced malformed YAML
A shell/Python/jinja generator that string-concatenates YAML can emit bad indentation or unquoted special characters, so the output is not parseable.
Missing version in the generated file
The generated config still needs version: 2.1 (and jobs/workflows). A fragment that omits the version header fails schema validation.
Path filtering emitted an empty config
With the path-filtering orb, when no mapping matches the changed files, the generated config can be empty or have no workflows - which compiles to nothing or errors.
How to fix it
Generate a complete, valid config and check it
- run:
name: Generate and validate
command: |
./scripts/gen.py > .circleci/generated.yml
head -1 .circleci/generated.yml # expect: version: 2.1
circleci config validate .circleci/generated.ymlAlways emit a runnable fallback workflow
- Ensure the generator writes
version: 2.1plus at least one job and workflow. - For path filtering, include a default mapping so a no-match change still produces a valid (possibly no-op) workflow.
- Prefer a YAML library over string concatenation to avoid indentation bugs.
How to prevent it
- Validate generated config in the setup job, before continuing.
- Build YAML with a serializer, not string templating.
- Provide a default/no-op workflow so path filtering never yields an empty config.