hasura/graphql-engine · error
cue formatting error: %w
Error message
cue formatting error: %w
What it means
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.
Source
Thrown at cli/internal/metadatautil/yaml.go:220
_, err := resolveTags(map[string]string{baseDirectoryKey: baseDirectory}, node, &filenames)
if err != nil {
return filenames, errors.E(op, err)
}
return filenames, nil
}
func YAMLToJSON(yamlbs []byte) ([]byte, error) {
var op errors.Op = "metadatautil.YAMLToJSON"
cueExpr, err := cueyaml.Extract("", yamlbs)
if err != nil {
return nil, errors.E(op, fmt.Errorf("cue extraction error: %w", err))
}
cueNode, err := format.Node(cueExpr)
if err != nil {
return nil, errors.E(op, fmt.Errorf("cue formatting error: %w", err))
}
cueValue := cuecontext.New().CompileBytes(cueNode)
jsonString, err := cuejson.Marshal(cueValue)
if err != nil {
return nil, errors.E(op, err)
}
return []byte(jsonString), nil
}
View on GitHub (pinned to 724551b9ae)
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
Example fix
// before: metadata.yaml using a merge key // defaults: &defaults // timeout: 10 // x: // <<: *defaults // after: expand anchors explicitly // defaults: // timeout: 10 // x: // timeout: 10
Defensive patterns
Strategy: fallback
Try / catch
jsonOut, err := metadatautil.YAMLToJSON(data)
if err != nil && strings.Contains(err.Error(), "cue formatting error") {
// fall back to a plain YAML->JSON converter
jsonOut, err = yamlToJSONGeneric(data)
} Prevention
- Avoid YAML anchors, merge keys and multi-document files in metadata
- Use server-exported metadata unmodified where possible
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- cue extraction error: %w
- cannot build %s from project: %w
- error getting actions file content: %w
- error in creating action: %w
- failed to get the matching platform for plugin %s: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/6a625132f1101dab.
Report an issue: GitHub.