{"record":{"id":"7f479d0aecd1be10","repo":"windmill-labs/windmill","slug":"error-parsing-yaml-path","errorCode":null,"errorMessage":"Error parsing yaml ${path}","messagePattern":"Error parsing yaml (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/utils/yaml.ts","lineNumber":34,"sourceCode":"const inlineFilesetTag: ScalarTag = {\n  tag: \"!inline_fileset\",\n  resolve(value: string) {\n    return \"!inline_fileset \" + value;\n  },\n};\n\nconst WINDMILL_CUSTOM_TAGS: ScalarTag[] = [inlineTag, inlineFilesetTag];\n\ntype YamlParseOptions = ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions;\n\nexport async function yamlParseFile(path: string, options: YamlParseOptions = {}) {\n  try {\n    return yamlParse(await readTextFile(path), {\n      ...options,\n      customTags: [...WINDMILL_CUSTOM_TAGS, ...((options.customTags as ScalarTag[] | undefined) ?? [])],\n    });\n  } catch (e) {\n    throw new Error(`Error parsing yaml ${path}`, { cause: e });\n  }\n}\n\nexport function yamlParseContent(\n  path: string,\n  content: string,\n  options: YamlParseOptions = {},\n) {\n  try {\n    return yamlParse(content, {\n      ...options,\n      customTags: [...WINDMILL_CUSTOM_TAGS, ...((options.customTags as ScalarTag[] | undefined) ?? [])],\n    });\n  } catch (e) {\n    throw new Error(`Error parsing yaml ${path}`, { cause: e });\n  }\n}\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/utils/yaml.ts#L16-L52","documentation":"`yamlParseFile` reads a file and parses it as YAML with Windmill's custom tags. If reading or parsing fails for any reason, it wraps the original error with `Error parsing yaml <path>` (keeping the cause) so the failing file is identified.","triggerScenarios":"Running commands that load YAML definitions (`wmill app`, `wmill script`/`runnable` from local files, `wmill lint raw-app`, local app flows) against a file with YAML syntax errors, tabs used for indentation, or an unsupported encoding thrown by `readTextFile`.","commonSituations":"Hand-edited YAML with bad indentation or duplicate keys; a file saved as UTF-16 by PowerShell; a nonexistent file path (read error wrapped too); windmill custom tags misused.","solutions":["Inspect the `cause` for the exact parser line/column and fix the syntax (common: tabs instead of spaces, wrong indentation)","Verify the file is UTF-8 encoded (readTextFile rejects UTF-16/32 and its errors get wrapped here)","Validate locally before deploying: `yq . <path>` or a YAML linter; check the path exists"],"exampleFix":"// before (script.yaml)\nsummary: x\n\ttabs cause parse error\n// after\nsummary: x\n  description: uses spaces","handlingStrategy":"try-catch","validationCode":"const yaml = require('js-yaml');\ntry { yaml.load(require('fs').readFileSync(path, 'utf8')); }\ncatch (e) { throw new Error(`${path} is not valid YAML: ${e.message}`); }","typeGuard":null,"tryCatchPattern":"try {\n  const def = await yamlParseFile(path);\n} catch (e) {\n  console.error(`YAML error in ${path}:`, e.cause ?? e);\n  // cause holds the original parser error with line/column details\n}","preventionTips":["Use spaces, never tabs, for YAML indentation","Lint YAML with a pre-commit hook (yamllint / `yq . file`)","Keep files saved as UTF-8 (readTextFile rejects UTF-16/32 and its errors get wrapped here)","Check the wrapped `cause` for the exact line/column before editing"],"tags":["yaml","parsing","cli","file","syntax"],"backgroundTag":"yaml-parse-error","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}