{"record":{"id":"49c7ca3e9a29e5e2","repo":"hasura/graphql-engine","slug":"cannot-unmarshal-server-metadata-to-json-w","errorCode":null,"errorMessage":"cannot unmarshal server metadata to json: %w","messagePattern":"cannot unmarshal server metadata to json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_diff.go","lineNumber":193,"sourceCode":"\topts.projectMetadataHandler.SetMetadataObjects(\n\t\tprojectmetadata.GetMetadataObjectsWithDir(opts.ec, opts.fromProjectDirectory),\n\t)\n\n\toldYaml, err := opts.projectMetadataHandler.BuildYAMLMetadata()\n\tif err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\tswitch opts.diffType {\n\tcase DifftypeJSON:\n\t\tnewJson, err := convertYamlToJsonWithIndent(newYaml)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"cannot unmarshal local metadata to json: %w\", err))\n\t\t}\n\n\t\toldJson, err := convertYamlToJsonWithIndent(oldYaml)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"cannot unmarshal server metadata to json: %w\", err))\n\t\t}\n\n\t\tif err := printMyersDiff(\n\t\t\tstring(newJson),\n\t\t\tstring(oldJson),\n\t\t\topts.toFriendlyName,\n\t\t\topts.fromFriendlyName,\n\t\t\topts.writer,\n\t\t\topts.disableColor,\n\t\t); err != nil {\n\t\t\treturn errors.E(op, err)\n\t\t}\n\n\t\treturn nil\n\tcase DifftypeYAML:\n\t\terr := printMyersDiff(\n\t\t\tstring(newYaml),\n\t\t\tstring(oldYaml),","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_diff.go#L175-L211","documentation":"Companion to the local-side error: during a json-type metadata diff between directories, converting the old directory's YAML metadata to JSON failed. The wrapped error identifies whether the YAML was unparseable or the resulting JSON could not be indented. Only the old (second) side's files are implicated.","triggerScenarios":"`hasura metadata diff --type-of-diff json <newDir> <oldDir>` where oldDir's metadata YAML is malformed: invalid syntax, duplicate keys, or merge-conflict remnants in its metadata files.","commonSituations":"Comparing against a baseline directory that was hand-edited or partially written, checking out an old branch whose metadata has conflict markers, or a stale export directory corrupted on disk.","solutions":["Lint the old directory's YAML files (yq '.' metadata/*.yaml) to find the broken file","Fix indentation/duplicate-key issues in the old side's metadata","Re-export a clean baseline: hasura metadata export into the old directory and retry the diff"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Shell: lint the old/baseline directory too\nfor f in olddir/metadata/*.yaml; do yq -e '.' \"$f\" >/dev/null || { echo \"bad: $f\"; exit 1; }; done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep baseline metadata directories clean exports","Check for merge-conflict markers after git merges"],"tags":["yaml","metadata-diff","parse-error"],"backgroundTag":"yaml-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}