hasura/graphql-engine · error

error in reading %s: %w

Error message

error in reading %s: %w

What it means

During Build, after converting SDL to metadata, the CLI failed reading the existing actions.yaml (GetActionsFileContent) which it needs to merge old handler definitions with the new SDL-derived actions. The wrapped error is typically a missing file or YAML parse failure.

Source

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

	sdlFromReq := types.SDLFromRequest{
		SDL: types.SDLPayload{
			Complete: graphqlFileContent,
		},
	}

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

	// Read actions.yaml
	oldAction, err := a.GetActionsFileContent()
	if err != nil {
		return nil, errors.E(op, a.error(fmt.Errorf("error in reading %s: %w", a.Filename(), err)))
	}

	for actionIndex, action := range oldAction.Actions {
		var isFound bool

		for newActionIndex, newActionObj := range sdlFromResp.Actions {
			if action.Name == newActionObj.Name {
				isFound = true
				sdlFromResp.Actions[newActionIndex].Permissions = oldAction.Actions[actionIndex].Permissions
				sdlFromResp.Actions[newActionIndex].Comment = oldAction.Actions[actionIndex].Comment
				sdlFromResp.Actions[newActionIndex].Definition.Timeout = oldAction.Actions[actionIndex].Definition.Timeout
				sdlFromResp.Actions[newActionIndex].Definition.Kind = oldAction.Actions[actionIndex].Definition.Kind
				sdlFromResp.Actions[newActionIndex].Definition.Handler = oldAction.Actions[actionIndex].Definition.Handler
				sdlFromResp.Actions[newActionIndex].Definition.ForwardClientHeaders = oldAction.Actions[actionIndex].Definition.ForwardClientHeaders
				sdlFromResp.Actions[newActionIndex].Definition.Headers = oldAction.Actions[actionIndex].Definition.Headers
				sdlFromResp.Actions[newActionIndex].Definition.RequestTransform = oldAction.Actions[actionIndex].Definition.RequestTransform
				sdlFromResp.Actions[newActionIndex].Definition.ResponseTransform = oldAction.Actions[actionIndex].Definition.ResponseTransform

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check the wrapped error: a YAML parse error names the line, a *PathError names a missing/permission problem
  2. Fix or restore actions.yaml from git; resolve merge conflict markers and validate with yamllint or `yaml.Marshal` round-trip
  3. If starting fresh, regenerate actions.yaml via `hasura actions create`
  4. Ensure read permissions on the file for the running user

Example fix

# before (invalid: tab indentation + conflict marker)
actions:
	- name: createUser
<<<<<<< HEAD
# after
actions:
  - name: createUser
    definition:
      handler: http://localhost:3000/api/createUser
Defensive patterns

Strategy: validation

Validate before calling

data, err := os.ReadFile(filepath.Join(metadataDir, "actions.yaml"))
if err != nil { return err }
var v any
if err := yaml.Unmarshal(data, &v); err != nil {
    return fmt.Errorf("actions.yaml is invalid YAML: %w", err)
}

Try / catch

if _, err := cfg.Build(ctx); err != nil {
    if strings.Contains(err.Error(), "error in reading actions.yaml") {
        // inspect wrapped error: yaml.TypeError -> fix file; PathError -> restore missing file
    }
}

Prevention

When it happens

Trigger: Running metadata export/build when metadata/actions/actions.yaml is missing, unreadable, or contains invalid YAML (tabs, bad indentation, truncated file from a conflicted merge).

Common situations: Git merge conflicts leaving conflict markers in actions.yaml; partially deleted or empty actions.yaml; tabs instead of spaces after hand editing; file not committed so CI clones lack it.

Related errors


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