{"record":{"id":"da7b93a4be49a3f4","repo":"hasura/graphql-engine","slug":"error-in-reading-s-file-w-da7b93","errorCode":null,"errorMessage":"error in reading %s file: %w","messagePattern":"error in reading (.+?) file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/metadataobject/actions/actions.go","lineNumber":79,"sourceCode":"\t}\n\n\treturn cfg\n}\n\nfunc (a *ActionConfig) Create(name string, introSchema any, deriveFrom string) error {\n\tvar op errors.Op = \"actions.ActionConfig.Create\"\n\n\terr := a.ensureCliExt()\n\tdefer a.cleanupCliExt()\n\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","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/metadataobject/actions/actions.go#L61-L97","documentation":"Thrown by Actions.Create when the actions.graphql file cannot be read while creating a new action. GetActionsGraphQLFileContent failed (file missing or unreadable), and the error wraps the graphql file name with the underlying cause.","triggerScenarios":"Running action creation (`hasura actions create X`) when actions.graphql is absent from the metadata directory, the metadata directory path is misconfigured, or the file has permissions that block reading.","commonSituations":"Fresh project where `hasura actions codegen` hasn't been initialized, custom metadata directory where actions.graphql wasn't created, or CI environments with restricted file permissions.","solutions":["Ensure actions.graphql exists in the configured metadata/actions directory","Run `hasura actions use-codegen` / create the file scaffold before calling Create","Verify the metadata directory path in config matches where the file lives","Check file read permissions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(metadataDir, \"actions\", \"actions.graphql\")); err != nil {\n\t// scaffold the file or run `hasura actions use-codegen` before Create\n}","typeGuard":null,"tryCatchPattern":"if err := actions.Create(name, derive, introSchema, dryRun); err != nil {\n\tif strings.Contains(err.Error(), \"error in reading actions.graphql\") {\n\t\t// create the missing scaffold, then retry\n\t}\n\treturn err\n}","preventionTips":["Run actions codegen init before scripted Create calls","Keep actions.graphql under version control","Validate the metadata directory layout before automation"],"tags":["hasura","actions","file-io","metadata"],"backgroundTag":"metadata-file-read-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}