{"record":{"id":"d5b16990270a6944","repo":"hasura/graphql-engine","slug":"expected-extension-to-be-one-of-v-but-got-s-on-f","errorCode":null,"errorMessage":"expected extension to be one of %v but got %s on file %s","messagePattern":"expected extension to be one of (.+?) but got (.+?) on file (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/seed/apply.go","lineNumber":27,"sourceCode":"\t\"github.com/hasura/graphql-engine/cli/v2\"\n\t\"github.com/hasura/graphql-engine/cli/v2/internal/errors\"\n\t\"github.com/hasura/graphql-engine/cli/v2/internal/hasura\"\n\t\"github.com/spf13/afero\"\n)\n\nfunc hasAllowedSeedFileExtensions(filename string) error {\n\tvar op errors.Op = \"seed.hasAllowedSeedFileExtensions\"\n\n\textension := filepath.Ext(filename)\n\n\tallowedExtensions := []string{\".sql\", \".SQL\"}\n\tif slices.Contains(allowedExtensions, extension) {\n\t\treturn nil\n\t}\n\n\treturn errors.E(\n\t\top,\n\t\tfmt.Errorf(\n\t\t\t\"expected extension to be one of %v but got %s on file %s\",\n\t\t\tallowedExtensions,\n\t\t\textension,\n\t\t\tfilename,\n\t\t),\n\t)\n}\n\n// ApplySeedsToDatabase will read all .sql files in the given\n// directory and apply it to hasura.\nfunc (d *Driver) ApplySeedsToDatabase(\n\tfs afero.Fs,\n\trootSeedsDirectory string,\n\tfilenames []string,\n\tsource cli.Source,\n) error {\n\tvar op errors.Op = \"seed.Driver.ApplySeedsToDatabase\"\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/seed/apply.go#L9-L45","documentation":"The seed-apply command only reads files with whitelisted extensions (the allowedExtensions list, e.g. .sql) from the seeds directory. hasAllowedSeedFileExtensions inspects each candidate file and rejects anything whose extension is not in that list, so non-SQL junk never reaches the database.","triggerScenarios":"A file in the seeds directory ends with an extension not in allowedExtensions: .txt, .sql.bak, .md, or no extension at all. Triggered by ApplySeedsToDatabase when iterating (explicit-file mode) or walking (directory mode) the seeds folder.","commonSituations":"Leaving README.md, backup files like 0-seed.sql.bak, editor swap files, or .DS_Store inside the seeds/ directory; or renaming seed files from .sql to something else and forgetting the whitelist only accepts .sql.","solutions":["Rename the file to use an allowed extension (.sql) if it is a real seed.","Move non-seed files (READMEs, backups, notes) out of the seeds directory.","Delete stray files like .DS_Store or editor temp files from seeds/.","Do not widen allowedExtensions unless you fully control the directory contents."],"exampleFix":"# before\nseeds/\n  0-seed.sql\n  notes.txt        # rejected: expected extension to be one of [.sql]\n\n# after\nseeds/\n  0-seed.sql\n# notes.txt moved to project root or docs/","handlingStrategy":"validation","validationCode":"var allowed = map[string]bool{\".sql\": true}\nfilepath.WalkDir(seedsDir, func(p string, d fs.DirEntry, err error) error {\n    if !d.IsDir() && !allowed[strings.ToLower(filepath.Ext(p))] {\n        return nil // skip, don't let the CLI reject it\n    }\n    return nil\n})","typeGuard":"func isAllowedSeedFile(name string, allowed []string) bool {\n    return slices.Contains(allowed, strings.ToLower(filepath.Ext(name)))\n}","tryCatchPattern":"if err := ApplySeedsToDatabase(...); err != nil && strings.Contains(err.Error(), \"expected extension to be one of\") {\n    // clean the seeds dir and re-run\n}","preventionTips":["Keep only .sql files in the seeds directory.","Store notes/backups outside seeds/ or with non-matching extensions the walker still skips (they cause errors — so just move them out).","Add a CI lint step: find seeds -type f ! -name '*.sql' fails the build."],"tags":["go","seeds","file-extension","validation","hasura-cli"],"backgroundTag":"file-extension-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}