hasura/graphql-engine · error
error getting actions file content: %w
Error message
error getting actions file content: %w
What it means
Thrown when no specific actions are passed to `hasura actions codegen`, so the CLI falls back to reading all actions from the actions file (actions.yaml in the metadata directory) via actionCfg.GetActionsFileContent(), and that read/parse fails. The actions file is missing, unreadable, or invalid YAML.
Source
Thrown at cli/commands/actions_codegen.go:129
if o.EC.Config.ActionConfig.Codegen.Framework == "" {
return errors.E(
op,
stderrors.New(`could not find codegen config. For adding codegen config, run:
hasura actions use-codegen`),
)
}
// if no actions are passed, perform codegen for all actions
o.EC.Spin("Generating code...")
var codegenActions []string
actionCfg := actions.New(o.EC, o.EC.MetadataDir)
if len(o.actions) == 0 {
actionsFileContent, err := actionCfg.GetActionsFileContent()
if err != nil {
return errors.E(op, fmt.Errorf("error getting actions file content: %w", err))
}
for _, action := range actionsFileContent.Actions {
codegenActions = append(codegenActions, action.Name)
}
} else {
codegenActions = o.actions
}
for _, actionName := range codegenActions {
err = actionCfg.Codegen(actionName, derivePayload)
if err != nil {
return errors.E(
op,
fmt.Errorf("error generating codegen for action %s: %w", actionName, err),
)
}
}View on GitHub (pinned to 724551b9ae)
Solutions
- Confirm actions.yaml exists under your metadata directory and lists at least one action.
- Validate the YAML (e.g. `yq . metadata/actions.yaml`) and fix syntax/structure (needs a top-level `actions:` list with `name` fields).
- Create an action first with `hasura actions create <name>` so the file is generated correctly.
- Check the --metadata-dir flag / HASURA_METADATA_DIR env points at the right folder.
Defensive patterns
Strategy: validation
Validate before calling
test -f metadata/actions.yaml && yq e '.actions[0].name' metadata/actions.yaml >/dev/null
Try / catch
Catch and check the wrapped error for YAML/missing-file causes; regenerate actions.yaml via `hasura actions create` or fix YAML before retrying.
Prevention
- Run `hasura actions create` before codegen.
- Lint actions.yaml in CI.
- Commit metadata files to the repo.
When it happens
Trigger: Running `hasura actions codegen` with no action name arguments when metadata/actions.yaml does not exist, has malformed YAML, lacks the expected `actions:` structure, or the metadata directory permissions deny reading.
Common situations: Running codegen before ever creating an action (`hasura actions create`), pointing --metadata-dir at the wrong directory, hand-editing actions.yaml and breaking indentation, or a fresh checkout missing uncommitted metadata files.
Related errors
- error in creating action: %w
- cue extraction error: %w
- cannot build %s from project: %w
- parsing yaml metadata to json: %w
- parsing metadata to yaml: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/e04cf9f19138bd86.
Report an issue: GitHub.