{"record":{"id":"6b0f9d2985fb04a9","repo":"hasura/graphql-engine","slug":"parsing-local-yaml-metadata-as-json-w","errorCode":null,"errorMessage":"parsing local yaml metadata as json: %w","messagePattern":"parsing local yaml metadata as json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/pkg/metadata/mode_handlers.go","lineNumber":192,"sourceCode":"\tr, err := apply(p, p.ec.MetadataMode)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\treturn r, nil\n}\n\nfunc (m *metadataModeYAMLHandler) Parse(p *ProjectMetadata) (io.Reader, error) {\n\tvar op errors.Op = \"metadata.metadataModeYAMLHandler.Parse\"\n\n\tmetadataYAML, err := os.ReadFile(p.ec.MetadataFile)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"reading metadata file: %w\", err))\n\t}\n\n\tmetadataJSON, err := metadatautil.YAMLToJSON(metadataYAML)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"parsing local yaml metadata as json: %w\", err))\n\t}\n\n\treturn bytes.NewReader(metadataJSON), nil\n}\n\nfunc (m *metadataModeYAMLHandler) Diff(p *ProjectMetadata) (io.Reader, error) {\n\tvar op errors.Op = \"metadata.metadataModeYAMLHandler.Diff\"\n\n\tr, err := diff(p)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\treturn r, nil\n}\n\nfunc (m *metadataModeYAMLHandler) Export(p *ProjectMetadata) (io.Reader, error) {\n\tvar op errors.Op = \"metadata.metadataModeYAMLHandler.Export\"","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/pkg/metadata/mode_handlers.go#L174-L210","documentation":"After successfully reading metadata.yaml, the YAML handler converts it to JSON via metadatautil.YAMLToJSON; invalid YAML (or YAML structures unmarshalable to JSON, like non-string map keys) fails here with 'parsing local yaml metadata as json'.","triggerScenarios":"Running a metadata command in YAML mode where metadata.yaml has a YAML syntax error (tabs, bad indentation, unclosed quotes) or duplicate keys/complex keys that can't map to JSON.","commonSituations":"Hand-edited metadata.yaml with tab indentation or merge conflict markers; duplicate top-level keys; pasting JSON-with-comments into a .yaml file; version skew where metadata schema keys changed.","solutions":["Lint the file: `yamllint metadata.yaml` or `hasura metadata diff` to surface the parse error position","Fix tabs→spaces, indentation, and remove conflict markers/duplicates","Re-export a known-good file (`hasura metadata export`) and reapply your changes incrementally","Keep CLI and server versions aligned"],"exampleFix":"# before (metadata.yaml)\nversion:\t3   # tab + bad structure\n\n# after\nversion: 3","handlingStrategy":"validation","validationCode":"var v any\nif err := yaml.Unmarshal(raw, &v); err != nil {\n    return fmt.Errorf(\"metadata.yaml invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := h.Parse(&p); err != nil {\n    if strings.Contains(err.Error(), \"parsing local yaml metadata as json\") {\n        // yamllint metadata.yaml; fix tabs/duplicate keys, then retry\n    }\n}","preventionTips":["Use spaces, never tabs, in metadata.yaml","Avoid duplicate keys and complex map keys","Lint metadata.yaml in CI before `hasura metadata apply`"],"tags":["metadata","yaml","json-conversion","hasura"],"backgroundTag":"yaml-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}