hasura/graphql-engine · error

error in writing config: %w

Error message

error in writing config: %w

What it means

Thrown when o.EC.WriteConfig(newConfig) fails while persisting the newly chosen codegen settings to config.yaml at the end of `hasura actions use-codegen`. This is a local file write/serialize error: unwritable file, invalid config state, or file locked by another process.

Source

Thrown at cli/commands/actions_use_codegen.go:245

		outputDir, err := util.GetFSPathPrompt(
			"Where do you want to place the codegen files?",
			o.EC.Config.ActionConfig.Codegen.OutputDir,
		)
		if err != nil {
			return errors.E(op, fmt.Errorf("error in getting output directory input: %w", err))
		}

		newCodegenExecutionConfig.OutputDir = outputDir
	} else {
		newCodegenExecutionConfig.OutputDir = o.outputDir
	}

	newConfig := o.EC.Config
	newConfig.ActionConfig.Codegen = newCodegenExecutionConfig

	err = o.EC.WriteConfig(newConfig)
	if err != nil {
		return errors.E(op, fmt.Errorf("error in writing config: %w", err))
	}

	o.EC.Spinner.Stop()
	o.EC.Logger.Info("Codegen configuration updated in config.yaml")

	return nil
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check permissions on config.yaml and its directory; chmod/chown as needed.
  2. Ensure the CLI process runs as a user with write access to the project.
  3. If config.yaml is corrupted, restore or regenerate it (hasura init) and re-run the selection.
Defensive patterns

Strategy: validation

Validate before calling

test -w config.yaml || chmod u+w config.yaml; yq e '.' config.yaml >/dev/null

Try / catch

Catch, fix config.yaml permissions/ownership, and re-run `hasura actions use-codegen` with the same flags.

Prevention

When it happens

Trigger: Finishing use-codegen when config.yaml is read-only, owned by another user, missing with an unwritable parent directory, or when the config object cannot be serialized (unexpected values).

Common situations: Running the CLI in a container/CI checkout as a non-root user without write access to the project dir; config.yaml permissions changed; editors or watchers locking the file on some platforms.

Related errors


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