hasura/graphql-engine · error
operation failed: %w
Error message
operation failed: %w
What it means
Init FSM failure: after SendEvent(createProjectDirectory) the state machine is in failedOperation, so the stored context.err (from createExecutionDirectory/createFiles) is wrapped as 'operation failed'. This aggregates the per-step init failures described in errors 49-57.
Source
Thrown at cli/commands/init.go:366
func (o *InitOptions) Run() error {
var op errors.Op = "commands.InitOptions.Run"
context := &initCtx{
ec: o.EC,
initOps: o,
logger: o.EC.Logger,
err: nil,
}
configInitFSM := newInitFSM()
err := configInitFSM.SendEvent(createProjectDirectory, context)
if err != nil {
return errors.E(op, err)
}
if configInitFSM.Current == failedOperation {
return errors.E(op, fmt.Errorf("operation failed: %w", context.err))
}
return nil
}
const (
creatingProjectDirectory stateType = "Creating project directory"
failedCreatingProjectDir stateType = "Failed to create project directory"
validatingEndpoint stateType = "Validating Endpoint"
failedValidatingEndpoint stateType = "Failed validating endpoint"
exportingMetadata stateType = "Exporting Metadata"
failedExportingMetadata stateType = "Failed to export Metadata"
creatingMigration stateType = "Creating Migration"
failedCreatingMigration stateType = "Failed creating Migration"
endState stateType = "End State"
)
const (View on GitHub (pinned to 724551b9ae)
Solutions
- Read the wrapped context.err to find the failing step and apply the matching fix (existing dir, permissions, URL validity)
- Pre-check the target directory (writable, non-existent, not already a Hasura project) before init in scripts
- Re-run init after cleaning the failed target directory
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight the whole init
if _, err := os.Stat(target); err == nil { log.Fatal("target exists") }
if _, err := url.ParseRequestURI(endpoint); endpoint != "" && err != nil { log.Fatal("bad endpoint") }
if err := os.MkdirAll(filepath.Dir(target), 0o755); err != nil { log.Fatal(err) } Try / catch
if err := initCmd.Run(); err != nil {
var inner error
if errors.As(err, &inner) { log.Printf("init step failed: %v", inner) }
// remediate (dir exists / perms / URL) then retry
} Prevention
- Pre-check target dir, permissions, and endpoint before init
- Make automation idempotent: unique dirs or cleanup before init
When it happens
Trigger: `hasura init` where directory creation or file scaffolding fails — existing directory, permission denial, read-only FS, invalid endpoint URL, or config write failure.
Common situations: Non-idempotent automation re-running `hasura init` into an existing folder; CI containers with restricted mounts; invalid --endpoint values.
Related errors
- operation failed: %w
- prompt exited: %w
- error getting current working directory: %w
- can't initialise hasura project in filesystem root: %w
- directory '%s' already exists
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/cb8085f7dafe4ec0.
Report an issue: GitHub.