{"record":{"id":"e94d764ecfa1c593","repo":"hasura/graphql-engine","slug":"parsing-metadata-to-yaml-w-e94d76","errorCode":null,"errorMessage":"parsing metadata to yaml: %w","messagePattern":"parsing metadata to yaml: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/pkg/metadata/mode_handlers.go","lineNumber":294,"sourceCode":"func export(p *ProjectMetadata, mode cli.MetadataMode) (io.Reader, error) {\n\tvar op errors.Op = \"metadata.export\"\n\n\tmetadata, err := p.ec.APIClient.V1Metadata.ExportMetadata()\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"exporting metadata from server: %w\", err))\n\t}\n\n\tvar metadataBytes []byte\n\n\tmetadataBytes, err = io.ReadAll(metadata)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"reading metadata from response: %w\", err))\n\t}\n\n\tif mode == cli.MetadataModeYAML {\n\t\tmetadataBytes, err = metadatautil.JSONToYAML(metadataBytes)\n\t\tif err != nil {\n\t\t\treturn nil, errors.E(op, fmt.Errorf(\"parsing metadata to yaml: %w\", err))\n\t\t}\n\t}\n\n\treturn bytes.NewReader(metadataBytes), nil\n}\n","sourceCodeStart":276,"sourceCodeEnd":300,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/pkg/metadata/mode_handlers.go#L276-L300","documentation":"When exporting in YAML mode, the CLI converts the JSON metadata returned by the server into YAML via metadatautil.JSONToYAML. This error means that conversion failed — typically because the server's metadata contains YAML-incompatible structures (non-string map keys like numbers/booleans, which YAML round-trips badly) or the JSON payload was malformed.","triggerScenarios":"Calling Export with mode == cli.MetadataModeYAML when the exported JSON metadata has map keys that cannot be represented as YAML scalar keys (e.g. numeric boolean keys from naming conventions/remote schema configs), or the payload contains data the YAML marshaller rejects.","commonSituations":"Projects using GraphQL naming conventions with boolean options that become map keys in metadata; metadata containing large numbers that lose precision; exotic remote schema or action definitions produced by plugins that serialize oddly.","solutions":["Export in JSON mode instead (default) — it preserves the exact server representation","Inspect the exported JSON to find keys that are not strings (numbers/booleans as object keys)","Update the CLI: newer releases fixed known JSONToYAML round-trip issues","If a specific object triggers it, simplify/remove that object from metadata and retry"],"exampleFix":"# before\nhasura metadata export  # with a config forcing YAML mode -> parsing metadata to yaml\n# after\nhasura metadata export  # default JSON mode; or fix metadata so keys are YAML-safe","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := pm.Export(ctx, cli.MetadataModeYAML); err != nil {\n    if strings.Contains(err.Error(), \"parsing metadata to yaml\") {\n        r, err = pm.Export(ctx, cli.MetadataModeJSON) // fallback preserves data\n    }\n}","preventionTips":["Prefer JSON export when metadata contains non-string-keyed objects","Keep CLI updated to pick up YAML round-trip fixes","Validate exported YAML by re-applying to a scratch project"],"tags":["yaml","parsing","metadata","export","hasura-cli"],"backgroundTag":"yaml-serialization-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}