hasura/graphql-engine · error
error in marshalling common: %w
Error message
error in marshalling common: %w
What it means
Create fails when yaml.Marshal of the consolidated actions config (common, which now holds the SDL-derived actions and custom types) returns an error. This is a serialization failure of the in-memory ActionConfig into actions.yaml, usually caused by fields that cannot round-trip through YAML.
Source
Thrown at cli/internal/metadataobject/actions/actions.go:236
for oldTypeObjIndex, oldTypeObj := range oldAction.CustomTypes.Scalars {
if customType.Name == oldTypeObj.Name {
sdlFromResp.Types.Scalars[customTypeIndex].Description = oldAction.CustomTypes.Scalars[oldTypeObjIndex].Description
sdlFromResp.Types.Scalars[customTypeIndex].Relationships = oldAction.CustomTypes.Scalars[oldTypeObjIndex].Relationships
break
}
}
}
var common types.Common
common.Actions = sdlFromResp.Actions
common.CustomTypes = sdlFromResp.Types
common.SetExportDefault()
// write actions.yaml
commonByt, err := yaml.Marshal(common)
if err != nil {
return errors.E(op, fmt.Errorf("error in marshalling common: %w", err))
}
err = os.WriteFile(filepath.Join(a.MetadataDir, a.Filename()), commonByt, 0o644)
if err != nil {
return errors.E(op, fmt.Errorf("error in writing %s file: %w", a.Filename(), err))
}
err = os.WriteFile(filepath.Join(a.MetadataDir, graphqlFileName), data, 0o644)
if err != nil {
return errors.E(op, fmt.Errorf("error in writing %s file: %w", graphqlFileName, err))
}
return nil
}
func (a *ActionConfig) Codegen(name string, derivePld types.DerivePayload) error {
var op errors.Op = "actions.ActionConfig.Codegen"
View on GitHub (pinned to 724551b9ae)
Solutions
- Check the wrapped error for the exact field yaml.Marshal choked on
- Upgrade the hasura CLI and the actions codegen extension to matching versions and retry
- Regenerate actions.yaml from scratch (delete and re-create) instead of merging with a hand-edited file
- If a custom type is involved, simplify it and re-add fields incrementally to find the offender
Defensive patterns
Strategy: try-catch
Try / catch
// err is *errors.E from hasura CLI; inspect .Op()/kind and the wrapped yaml error
if err := actionCfg.Create(ctx); err != nil {
var yamlErr *yaml.TypeError
if errors.As(err, &yamlErr) {
for _, line := range yamlErr.Errors { log.Printf("yaml field issue: %s", line) }
}
return err
} Prevention
- Keep the CLI and codegen extension versions in sync so emitted action structs match the marshaler
- Don't hand-edit generated sections of actions.yaml
- Pin the hasura CLI version in CI to avoid surprise schema changes
When it happens
Trigger: Calling actions Create after the SDL conversion step, when the parsed action objects contain types, custom types, or handler definitions with fields yaml.Marshal cannot encode (e.g. maps with non-string keys, channels, unsupported marshaler output).
Common situations: A version mismatch between the CLI and the codegen extension producing action metadata with unexpected field shapes; hand-edited actions.yaml introducing incompatible structures; custom types with invalid YAML tags.
Related errors
- unable to marshal run_sql args in %s: %w
- error in marshalling actions, custom_types from metadata: %w
- error in marshaling common: %w
- parsing metadata to yaml: %w
- parsing yaml metadata to json: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/87e9d19cb116044d.
Report an issue: GitHub.