hasura/graphql-engine · error

error in unmarshal to common: %w

Error message

error in unmarshal to common: %w

What it means

Export re-decodes the freshly marshaled actions YAML into a types.Common struct; failure here means the serialized actions/custom_types payload does not conform to the Common schema expected by the export pipeline.

Source

Thrown at cli/internal/metadataobject/actions/actions.go:587

	if v, ok := metadata[metadataobject.CustomTypesKey]; ok {
		actions[metadataobject.CustomTypesKey] = v
	}

	ymlByt := new(bytes.Buffer)
	if err := metadataobject.GetEncoder(ymlByt).Encode(actions); err != nil {
		return nil, errors.E(
			op,
			a.error(
				fmt.Errorf("error in marshalling actions, custom_types from metadata: %w", err),
			),
		)
	}

	var common types.Common

	err = yaml.NewDecoder(ymlByt).Decode(&common)
	if err != nil {
		return nil, errors.E(op, a.error(fmt.Errorf("error in unmarshal to common: %w", err)))
	}

	var sdlToReq types.SDLToRequest

	sdlToReq.Types = common.CustomTypes
	sdlToReq.Actions = common.Actions

	sdlToResp, err := a.cliExtensionConfig.ConvertMetadataToSDL(sdlToReq)
	if err != nil {
		return nil, errors.E(
			op,
			a.error(fmt.Errorf("error in converting metadata to sdl: %w", err)),
		)
	}

	common.SetExportDefault()

	commonByt := new(bytes.Buffer)

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Validate the actions metadata against the version of the CLI being used (check for CLI/metadata version drift)
  2. Simplify the metadata to known fields and re-export
  3. Upgrade or align the CLI version with the metadata format
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate metadata parses as the expected schema before export
var c types.Common
if err := yaml.Unmarshal(raw, &c); err != nil { /* fix metadata first */ }

Try / catch

if err := obj.Export(ctx); err != nil {
  if strings.Contains(err.Error(), "error in unmarshal to common") {
    // metadata format drift: align CLI version or fix fields
  }
}

Prevention

When it happens

Trigger: Calling Export() when the intermediate YAML (actions + custom_types) contains fields or shapes that types.Common cannot unmarshal, e.g. unexpected nested structures or duplicate keys resolved into incompatible types.

Common situations: Version mismatch between the CLI and the metadata spec; hand-crafted metadata with extra/renamed fields; corrupt metadata files.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/c22f624bccec154e. Report an issue: GitHub.