{"record":{"id":"6a625132f1101dab","repo":"hasura/graphql-engine","slug":"cue-formatting-error-w-6a6251","errorCode":null,"errorMessage":"cue formatting error: %w","messagePattern":"cue formatting error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/metadatautil/yaml.go","lineNumber":220,"sourceCode":"\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":202,"sourceCodeEnd":232,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/metadatautil/yaml.go#L202-L232","documentation":"Thrown by metadatautil.YAMLToJSON when format.Node fails to pretty-print the CUE expression that was just successfully extracted from YAML. This is an internal CUE formatting failure, not a user YAML syntax problem — extraction already succeeded. It is rare and usually indicates a malformed/unexpected AST node produced by the extractor.","triggerScenarios":"Calling YAMLToJSON on YAML that parses but contains exotic constructs (complex anchors, merge keys, unusual scalar forms) that produce a CUE AST format.Node cannot render. Practically any YAMLToJSON caller can surface it, but the extraction step (error 290) fails far more often.","commonSituations":"Rare; seen with unusual YAML generated by other tools (Ansible-style anchors, multi-document YAML pasted into metadata.yaml). Essentially never hit on server-exported metadata.","solutions":["Simplify the YAML: remove anchors, aliases, merge keys (<<:) and multi-document separators (---)","Convert the YAML to JSON with an external tool (yq -o=json) and use JSON metadata instead","Report upstream to the CUE project with the minimal YAML that reproduces it"],"exampleFix":"// before: metadata.yaml using a merge key\n// defaults: &defaults\n//   timeout: 10\n// x:\n//   <<: *defaults\n\n// after: expand anchors explicitly\n// defaults:\n//   timeout: 10\n// x:\n//   timeout: 10","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"jsonOut, err := metadatautil.YAMLToJSON(data)\nif err != nil && strings.Contains(err.Error(), \"cue formatting error\") {\n\t// fall back to a plain YAML->JSON converter\n\tjsonOut, err = yamlToJSONGeneric(data)\n}","preventionTips":["Avoid YAML anchors, merge keys and multi-document files in metadata","Use server-exported metadata unmodified where possible"],"tags":["go","cue","formatting","yaml","hasura-cli"],"backgroundTag":"yaml-to-json-conversion-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}