hasura/graphql-engine · error
parsing yaml metadata to json: %w
Error message
parsing yaml metadata to json: %w
What it means
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.
Source
Thrown at cli/pkg/metadata/mode_handlers.go:235
return r, nil
}
func apply(p *ProjectMetadata, mode cli.MetadataMode) (io.Reader, error) {
var (
op errors.Op = "metadata.apply"
localMetadataBytes []byte
err error
)
localMetadataBytes, err = os.ReadFile(p.ec.MetadataFile)
if err != nil {
return nil, errors.E(op, fmt.Errorf("reading metadata file: %w", err))
}
if mode == cli.MetadataModeYAML {
localMetadataBytes, err = metadatautil.YAMLToJSON(localMetadataBytes)
if err != nil {
return nil, errors.E(op, fmt.Errorf("parsing yaml metadata to json: %w", err))
}
}
var metadata any
err = json.Unmarshal(localMetadataBytes, &metadata)
if err != nil {
return nil, errors.E(
op,
errors.KindBadInput,
fmt.Errorf("parsing metadata as json: %w", err),
)
}
if p.ec.Config.Version == cli.V2 {
r, err := cli.GetCommonMetadataOps(p.ec).
ReplaceMetadata(bytes.NewReader(localMetadataBytes))
if err != nil {View on GitHub (pinned to 724551b9ae)
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
Example fix
# before (metadata.yaml) version: 3 metadata: - type: table # mixed tabs/odd structure -> parsing yaml metadata to json # after version: 3 metadata: - type: table
Defensive patterns
Strategy: validation
Validate before calling
import "gopkg.in/yaml.v3"
var v any
if err := yaml.Unmarshal(raw, &v); err != nil {
return fmt.Errorf("metadata.yaml is not valid YAML: %w", err)
} Prevention
- Run yamllint on metadata files in CI
- Configure your editor to use spaces, never tabs, for YAML
- Resolve merge conflicts fully before applying metadata
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- parsing metadata to yaml: %w
- error getting actions file content: %w
- error in creating action: %w
- parsing yaml metadata to json: %w
- cue extraction error: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/5ac70d93685f65c4.
Report an issue: GitHub.