hasura/graphql-engine · warning

action %s already exists in %s

Error message

action %s already exists in %s

What it means

Returned by Actions.Create when the requested action name already exists in the existing actions.yaml/GraphQL definitions. Create refuses to overwrite, so duplicate names are rejected before any editor or conversion step runs.

Source

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

	if err != nil {
		return errors.E(op, err)
	}

	// Read the content of graphql file
	graphqlFileContent, err := a.GetActionsGraphQLFileContent()
	if err != nil {
		return errors.E(op, fmt.Errorf("error in reading %s file: %w", graphqlFileName, err))
	}
	// Read actions.yaml
	oldAction, err := a.GetActionsFileContent()
	if err != nil {
		return errors.E(op, fmt.Errorf("error in reading %s file: %w", a.Filename(), err))
	}
	// check if action already present
	for _, currAction := range oldAction.Actions {
		if currAction.Name == name {
			return errors.E(op, fmt.Errorf("action %s already exists in %s", name, graphqlFileName))
		}
	}

	var defaultSDL string
	if introSchema == nil {
		defaultSDL = `type Mutation {
	# Define your action as a mutation here
	` + name + ` (arg1: SampleInput!): SampleOutput
}

type SampleOutput {
	accessToken: String!
}

input SampleInput {
	username: String!
	password: String!
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Choose a different, unique action name
  2. Delete or rename the existing action in actions.yaml and actions.graphql first
  3. If the previous create partially completed, clean up its artifacts before retrying
Defensive patterns

Strategy: validation

Validate before calling

existing, _ := actions.GetActionsFileContent()
for _, a := range existing.Actions {
	if a.Name == newName {
		log.Fatalf("action %s already exists", newName)
	}
}

Try / catch

if err := actions.Create(name, ...); err != nil {
	if strings.Contains(err.Error(), "already exists") {
		// pick a new name or remove the old action; not a transient error
	}
	return err
}

Prevention

When it happens

Trigger: Calling Create(name, ...) where an action with the same name already appears in the Actions list parsed from actions.yaml — e.g. running `hasura actions create sameName` twice.

Common situations: Re-running a create command after a partial failure, scripted scaffolding that assumes a clean state, or copy-pasted examples colliding with existing actions.

Related errors


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