Skip to content
Latchkey

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.

job log
Config compilation failed for generated config:
  Unable to parse YAML: did not find expected key
  in '.circleci/generated.yml', line 7, column 3

Common 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

.circleci/config.yml
- 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.yml

Always emit a runnable fallback workflow

  1. Ensure the generator writes version: 2.1 plus at least one job and workflow.
  2. For path filtering, include a default mapping so a no-match change still produces a valid (possibly no-op) workflow.
  3. 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.

Frequently asked questions

What causes "invalid generated config"?
A shell/Python/jinja generator that string-concatenates YAML can emit bad indentation or unquoted special characters, so the output is not parseable.
How do I fix invalid generated config?
Generate a complete, valid config and check it

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card