{"record":{"id":"5ac70d93685f65c4","repo":"hasura/graphql-engine","slug":"parsing-yaml-metadata-to-json-w-5ac70d","errorCode":null,"errorMessage":"parsing yaml metadata to json: %w","messagePattern":"parsing yaml metadata to json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/pkg/metadata/mode_handlers.go","lineNumber":235,"sourceCode":"\treturn r, nil\n}\n\nfunc apply(p *ProjectMetadata, mode cli.MetadataMode) (io.Reader, error) {\n\tvar (\n\t\top                 errors.Op = \"metadata.apply\"\n\t\tlocalMetadataBytes []byte\n\t\terr                error\n\t)\n\n\tlocalMetadataBytes, 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\tif mode == cli.MetadataModeYAML {\n\t\tlocalMetadataBytes, err = metadatautil.YAMLToJSON(localMetadataBytes)\n\t\tif err != nil {\n\t\t\treturn nil, errors.E(op, fmt.Errorf(\"parsing yaml metadata to json: %w\", err))\n\t\t}\n\t}\n\n\tvar metadata any\n\n\terr = json.Unmarshal(localMetadataBytes, &metadata)\n\tif err != nil {\n\t\treturn nil, errors.E(\n\t\t\top,\n\t\t\terrors.KindBadInput,\n\t\t\tfmt.Errorf(\"parsing metadata as json: %w\", err),\n\t\t)\n\t}\n\n\tif p.ec.Config.Version == cli.V2 {\n\t\tr, err := cli.GetCommonMetadataOps(p.ec).\n\t\t\tReplaceMetadata(bytes.NewReader(localMetadataBytes))\n\t\tif err != nil {","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/pkg/metadata/mode_handlers.go#L217-L253","documentation":"During metadata apply, when the metadata mode is YAML, the CLI converts the local YAML metadata to JSON before sending it to the server. This error indicates the YAML->JSON conversion failed, almost always because the metadata file is not valid YAML (syntax errors, tabs, duplicated keys, or binary/non-text content). It is purely a local parsing failure, not a server error.","triggerScenarios":"Calling Apply with mode == cli.MetadataModeYAML where the metadata file contains invalid YAML: bad indentation, tab characters, unclosed quotes/brackets, or multiple YAML documents. metadatautil.YAMLToJSON returns an error which is wrapped here.","commonSituations":"Hand-editing metadata.yaml and breaking indentation; copy-pasting JSON fragments with tabs into the YAML file; merge conflicts left unresolved in metadata.yaml; switching a project from JSON metadata to YAML and leaving malformed content.","solutions":["Validate the file with a YAML linter or `yamllint metadata/metadata.yaml` and fix syntax errors","Check for tab characters (YAML requires spaces) and unresolved merge-conflict markers","Compare against a fresh `hasura metadata export` output to spot structural differences","If the file is actually JSON, run apply with the JSON metadata mode instead of YAML"],"exampleFix":"# before (metadata.yaml)\nversion: 3\nmetadata:\n  -   type: table   # mixed tabs/odd structure -> parsing yaml metadata to json\n# after\nversion: 3\nmetadata:\n  - type: table","handlingStrategy":"validation","validationCode":"import \"gopkg.in/yaml.v3\"\nvar v any\nif err := yaml.Unmarshal(raw, &v); err != nil {\n    return fmt.Errorf(\"metadata.yaml is not valid YAML: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run yamllint on metadata files in CI","Configure your editor to use spaces, never tabs, for YAML","Resolve merge conflicts fully before applying metadata"],"tags":["yaml","parsing","metadata","hasura-cli"],"backgroundTag":"yaml-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}