{"record":{"id":"e91d67060050c7ce","repo":"hasura/graphql-engine","slug":"cannot-convert-yaml-to-json-w","errorCode":null,"errorMessage":"cannot convert yaml to json: %w","messagePattern":"cannot convert yaml to json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_diff.go","lineNumber":298,"sourceCode":"\t\treturn errors.E(op, err)\n\t}\n\n\tif !file.IsDir() {\n\t\treturn errors.E(\n\t\t\top,\n\t\t\tfmt.Errorf(\"metadata diff only works with folder but got file %s\", path),\n\t\t)\n\t}\n\n\treturn nil\n}\n\nfunc convertYamlToJsonWithIndent(yamlByt []byte) ([]byte, error) {\n\tvar op errors.Op = \"commands.convertYamlToJsonWithIndent\"\n\n\tjsonByt, err := metadatautil.YAMLToJSON(yamlByt)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"cannot convert yaml to json: %w\", err))\n\t}\n\n\tvar jsonBuf bytes.Buffer\n\n\terr = json.Indent(&jsonBuf, jsonByt, \"\", \"  \")\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"cannot indent json: %w\", err))\n\t}\n\n\treturn jsonBuf.Bytes(), nil\n}\n","sourceCodeStart":280,"sourceCodeEnd":310,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_diff.go#L280-L310","documentation":"convertYamlToJsonWithIndent first converts YAML bytes to JSON via metadatautil.YAMLToJSON; if the YAML cannot be parsed into a form suitable for JSON conversion, this error wraps the failure. Callers are the metadata diff conversions for json and unified-json difftypes.","triggerScenarios":"Any metadata diff with a JSON output type where one side's YAML metadata is syntactically invalid or contains structures that cannot map to JSON (e.g. non-string keys that YAMLToJSON rejects).","commonSituations":"Invalid YAML from hand edits, duplicate mapping keys, binary/tags in YAML that the converter rejects, or metadata files from incompatible Hasura versions with different schemas.","solutions":["Run yq over the metadata YAML files to find and fix parse errors","Regenerate metadata via hasura metadata export for a known-good baseline","Check for duplicate keys — strict YAML parsers reject them even when the file 'looks fine'"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Go: pre-flight conversion per file\nif _, err := metadatautil.YAMLToJSON(yamlBytes); err != nil {\n  return fmt.Errorf(\"pre-flight failed for %s: %w\", name, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use strict YAML linting (duplicate-key detection) in CI","Regenerate corrupted metadata from the server"],"tags":["yaml","json","conversion","metadata-diff"],"backgroundTag":"yaml-to-json-conversion-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}