hasura/graphql-engine · error
error in applying metadata: %w
Error message
error in applying metadata: %w
What it means
After writing the new action to metadata, `hasura actions create` immediately applies metadata to the server by running MetadataApplyOptions.Run(); any failure from that apply (bad metadata, server rejection, connectivity) is wrapped with this message.
Source
Thrown at cli/commands/actions_create.go:114
}
// create new action
o.EC.Spin("Creating the action...")
actionCfg := actions.New(o.EC, o.EC.MetadataDir)
o.EC.Spinner.Stop()
err = actionCfg.Create(o.name, introSchema, o.deriveFrom)
if err != nil {
return errors.E(op, fmt.Errorf("error in creating action: %w", err))
}
opts := &MetadataApplyOptions{
EC: o.EC,
}
err = opts.Run()
if err != nil {
return errors.E(op, fmt.Errorf("error in applying metadata: %w", err))
}
o.EC.Logger.WithField("name", o.name).Infoln("action created")
// if codegen config not present, skip codegen
if o.EC.Config.ActionConfig.Codegen.Framework == "" {
if o.withCodegen {
return errors.E(
op,
stderrors.New(`could not find codegen config. For adding codegen config, run:
hasura actions use-codegen`),
)
}
return nil
}
View on GitHub (pinned to 724551b9ae)
Solutions
- Inspect the wrapped apply error — it usually contains the Hasura error path (e.g. 'action A: type T not found').
- Fix the reported inconsistency in metadata/actions.yaml and types.yaml.
- Re-run `hasura metadata apply` once the server-side conflict is resolved.
- Verify endpoint/admin-secret and server connectivity at apply time.
Defensive patterns
Strategy: retry
Validate before calling
hasura metadata export --endpoint $ENDPOINT --admin-secret $SECRET # proves apply path works
Try / catch
Catch the apply error; the file changes already succeeded, so fix the reported metadata inconsistency and run `hasura metadata apply` separately.
Prevention
- Dry-run metadata validity (`hasura metadata export`) in CI.
- Keep types.yaml in sync with actions.yaml.
- Ensure server permissions for metadata writes.
When it happens
Trigger: The freshly written metadata is rejected by the Hasura engine (invalid type definition, conflicting action name on the server), the server is unreachable mid-run, or the admin secret lacks permission to apply metadata.
Common situations: Metadata referencing types not defined in types.yaml, server already has a conflicting action, transient network drop between file write and apply, or running create against a production endpoint with restricted permissions.
Related errors
- error getting actions file content: %w
- error in creating action: %w
- cannot reload metadata: %w
- cannot export metadata from server: %w
- cue extraction error: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/c12654803634117e.
Report an issue: GitHub.