{"record":{"id":"736c12d1a81c0e18","repo":"hasura/graphql-engine","slug":"cue-extraction-error-w","errorCode":null,"errorMessage":"cue extraction error: %w","messagePattern":"cue extraction error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/metadatautil/yaml.go","lineNumber":215,"sourceCode":"\tvar (\n\t\top        errors.Op = \"metadatautil.GetIncludeTagFiles\"\n\t\tfilenames []string\n\t)\n\n\t_, err := resolveTags(map[string]string{baseDirectoryKey: baseDirectory}, node, &filenames)\n\tif err != nil {\n\t\treturn filenames, errors.E(op, err)\n\t}\n\n\treturn filenames, nil\n}\n\nfunc YAMLToJSON(yamlbs []byte) ([]byte, error) {\n\tvar op errors.Op = \"metadatautil.YAMLToJSON\"\n\n\tcueExpr, err := cueyaml.Extract(\"\", yamlbs)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"cue extraction error: %w\", err))\n\t}\n\n\tcueNode, err := format.Node(cueExpr)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"cue formatting error: %w\", err))\n\t}\n\n\tcueValue := cuecontext.New().CompileBytes(cueNode)\n\n\tjsonString, err := cuejson.Marshal(cueValue)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\treturn []byte(jsonString), nil\n}\n","sourceCodeStart":197,"sourceCodeEnd":232,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/metadatautil/yaml.go#L197-L232","documentation":"Thrown by metadatautil.YAMLToJSON when the underlying CUE YAML parser (cueyaml.Extract) cannot parse the input YAML bytes into a CUE expression. It always wraps a lower-level parse error, so the %w detail names the exact line/column of the malformed YAML. It means the input is not syntactically valid YAML (or uses constructs the CUE extractor cannot represent).","triggerScenarios":"Calling YAMLToJSON with YAML containing bad indentation, unclosed quotes/brackets, tabs used for indentation, duplicate keys the CUE extractor rejects, or an empty/garbage []byte. Any caller pipeline (buildAddSourceBulkRequest, apply, ConvertMetadataToSDL, convertYamlToJsonWithIndent) that feeds an unvalidated metadata.yaml or user-supplied YAML hits this.","commonSituations":"A hand-edited metadata.yaml with a typo, a YAML file with Windows line endings mixed with tabs, a metadata file truncated by a failed git merge, or YAML aliases/anchors unsupported by the CUE extractor.","solutions":["Paste the YAML into a linter (yamllint or yamlchecker.com) and fix the syntax error named in the wrapped error message","Run the CLI with verbose output to see the full wrapped cue extraction error including line/column","Check for tabs used for indentation and replace with spaces","Re-export the metadata from a known-good server (hasura metadata export) and reapply your changes incrementally"],"exampleFix":"// before (broken YAML):\n// version: 3\n// metadata:\n// \tbackend_configs:   # tab indentation\n//     dataconnector: foo\n\n// after (valid YAML, spaces only):\n// version: 3\n// metadata:\n//   backend_configs:\n//     dataconnector: foo","handlingStrategy":"validation","validationCode":"import \"gopkg.in/yaml.v3\"\n\nfunc validateYAML(data []byte) error {\n\tvar v any\n\treturn yaml.Unmarshal(data, &v)\n}","typeGuard":null,"tryCatchPattern":"if _, err := metadatautil.YAMLToJSON(data); err != nil {\n\tif strings.Contains(err.Error(), \"cue extraction error\") {\n\t\t// surface the wrapped parse detail to the user for the offending YAML\n\t\treturn fmt.Errorf(\"invalid YAML metadata: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Lint all metadata YAML files in CI with yamllint before running CLI commands","Never hand-tab YAML; configure your editor to use spaces for YAML","Prefer JSON metadata format if files are machine-generated"],"tags":["go","yaml","cue","metadata","parse-error","hasura-cli"],"backgroundTag":"yaml-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}