{"record":{"id":"30f2d3f85cb39803","repo":"hasura/graphql-engine","slug":"action-s-already-exists-in-s","errorCode":null,"errorMessage":"action %s already exists in %s","messagePattern":"action (.+?) already exists in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli/internal/metadataobject/actions/actions.go","lineNumber":89,"sourceCode":"\n\tif err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\t// Read the content of graphql file\n\tgraphqlFileContent, err := a.GetActionsGraphQLFileContent()\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"error in reading %s file: %w\", graphqlFileName, err))\n\t}\n\t// Read actions.yaml\n\toldAction, err := a.GetActionsFileContent()\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"error in reading %s file: %w\", a.Filename(), err))\n\t}\n\t// check if action already present\n\tfor _, currAction := range oldAction.Actions {\n\t\tif currAction.Name == name {\n\t\t\treturn errors.E(op, fmt.Errorf(\"action %s already exists in %s\", name, graphqlFileName))\n\t\t}\n\t}\n\n\tvar defaultSDL string\n\tif introSchema == nil {\n\t\tdefaultSDL = `type Mutation {\n\t# Define your action as a mutation here\n\t` + name + ` (arg1: SampleInput!): SampleOutput\n}\n\ntype SampleOutput {\n\taccessToken: String!\n}\n\ninput SampleInput {\n\tusername: String!\n\tpassword: String!\n}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/metadataobject/actions/actions.go#L71-L107","documentation":"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.","triggerScenarios":"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.","commonSituations":"Re-running a create command after a partial failure, scripted scaffolding that assumes a clean state, or copy-pasted examples colliding with existing actions.","solutions":["Choose a different, unique action name","Delete or rename the existing action in actions.yaml and actions.graphql first","If the previous create partially completed, clean up its artifacts before retrying"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"existing, _ := actions.GetActionsFileContent()\nfor _, a := range existing.Actions {\n\tif a.Name == newName {\n\t\tlog.Fatalf(\"action %s already exists\", newName)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := actions.Create(name, ...); err != nil {\n\tif strings.Contains(err.Error(), \"already exists\") {\n\t\t// pick a new name or remove the old action; not a transient error\n\t}\n\treturn err\n}","preventionTips":["List existing actions before scripted creation","Use deterministic unique names in generators","Clean up partially created actions before re-running scripts"],"tags":["hasura","actions","duplicate","validation"],"backgroundTag":"duplicate-resource-conflict","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}