{"record":{"id":"9ce8759eb167be3f","repo":"hasura/graphql-engine","slug":"cannot-indent-json-w","errorCode":null,"errorMessage":"cannot indent json: %w","messagePattern":"cannot indent json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_diff.go","lineNumber":305,"sourceCode":"\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":287,"sourceCodeEnd":310,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_diff.go#L287-L310","documentation":"The second stage of convertYamlToJsonWithIndent: YAMLToJSON succeeded, but json.Indent failed to re-indent the produced JSON. This means the intermediate JSON was malformed (invalid JSON syntax), which normally indicates the YAML produced a JSON document encoding the converter couldn't handle (multiple documents, or non-JSON-compatible output).","triggerScenarios":"Metadata YAML that converts to something json.Indent rejects — e.g. multi-document YAML (--- separators) producing concatenated JSON, or YAML with values that serialize outside JSON's grammar.","commonSituations":"Concatenating multiple exported metadata files into one YAML with multiple documents, hand-crafted YAML with exotic tags, or a metadatautil version skew after upgrading the CLI.","solutions":["Ensure each metadata YAML file contains a single document (remove extra --- separators)","Regenerate metadata files with hasura metadata export rather than concatenating manually","Report/upgrade if the file is a clean export — this can indicate a CLI bug in metadatautil"],"exampleFix":"# before (multi-document file)\n---\nargs: {}\n---\nversion: 3\n# after (single document per file)\nargs: {}","handlingStrategy":"validation","validationCode":"// Go: reject multi-document YAML before converting\nif bytes.Contains(yamlByt, []byte(\"\\n---\\n\")) {\n  return fmt.Errorf(\"multi-document YAML not supported\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One YAML document per metadata file","Never concatenate exported files manually"],"tags":["json","indent","yaml","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"}