{"record":{"id":"67563bfcc9fd9fb8","repo":"hasura/graphql-engine","slug":"invalid-yaml-file-s-w","errorCode":null,"errorMessage":"invalid yaml file: %s: %w","messagePattern":"invalid yaml file: (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/migrate/source/parse.go","lineNumber":134,"sourceCode":"\treturn nil, errors.E(op, ErrParse)\n}\n\n// Validate file to check for empty sql or yaml content.\nfunc IsEmptyFile(m *Migration, directory string) (bool, error) {\n\tvar op errors.Op = \"source.IsEmptyFile\"\n\n\tdata, err := os.ReadFile(filepath.Join(directory, m.Raw))\n\tif err != nil {\n\t\treturn false, errors.E(op, fmt.Errorf(\"cannot read file %s: %w\", m.Raw, err))\n\t}\n\n\tswitch direction := m.Direction; direction {\n\tcase MetaUp, MetaDown:\n\t\tvar t []any\n\n\t\terr = yaml.Unmarshal(data, &t)\n\t\tif err != nil {\n\t\t\treturn false, errors.E(op, fmt.Errorf(\"invalid yaml file: %s: %w\", m.Raw, err))\n\t\t}\n\n\t\tif len(t) == 0 {\n\t\t\treturn false, nil\n\t\t}\n\tcase Up, Down:\n\t\tif string(data) == \"\" {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\n\treturn true, nil\n}\n","sourceCodeStart":116,"sourceCodeEnd":148,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/migrate/source/parse.go#L116-L148","documentation":"Produced by IsEmptyFile when a migration marked as YAML (direction MetaUp/MetaDown, i.e. a .yaml migration) fails to unmarshal as a YAML list. The CLI expects YAML migrations to decode into []any; malformed YAML (tabs, bad indentation, scalar at top level) makes yaml.Unmarshal fail and the scan aborts.","triggerScenarios":"Any migrations/*.up.yaml or *.down.yaml file that is not valid YAML or not a top-level sequence — e.g. a mapping {key: value}, a bare scalar, tab indentation, or truncated content. Hit on any migrate command that scans the source (apply, status, create validation).","commonSituations":"Hand-editing YAML migrations with tabs (illegal in YAML); pasting SQL into a .yaml file; converting .sql migrations to .yaml without wrapping statements in a list (`- args: ...`); merge conflicts left in the file.","solutions":["Validate the offending file with a YAML linter or `yamllint migrations/<file>`","Ensure the top level is a list of actions, each item like `- type: run_sql\\n  args: ...`","Replace tabs with spaces and fix indentation","If the migration was meant to be SQL, use a .sql extension instead"],"exampleFix":"# before (migrations/05_seed.up.yaml)\nversion: 2   # mapping, not a list -> invalid yaml file\n\n# after\n- type: run_sql\n  args:\n    sql: SELECT 1;","handlingStrategy":"validation","validationCode":"// Validate a YAML migration parses as a list before scanning\nvar t []any\nif err := yaml.Unmarshal(raw, &t); err != nil {\n    return fmt.Errorf(\"migration %s is not a YAML list: %w\", name, err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := source.IsEmptyFile(m, dir); err != nil {\n    if strings.Contains(err.Error(), \"invalid yaml file\") {\n        // yamllint the file; fix tabs/structure\n    }\n}","preventionTips":["Use spaces (never tabs) in YAML migrations","Model new YAML migrations on generated examples","Run yamllint in CI over migrations/"],"tags":["yaml","migrations","validation","hasura"],"backgroundTag":"yaml-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}