{"record":{"id":"4f48fa0c911f3089","repo":"hasura/graphql-engine","slug":"no-data-provided","errorCode":null,"errorMessage":"no data provided","messagePattern":"no data provided","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/seed/create.go","lineNumber":34,"sourceCode":"\t\"github.com/spf13/afero\"\n)\n\n// CreateSeedOpts has the list of options required\n// to create a seed file.\ntype CreateSeedOpts struct {\n\tUserProvidedSeedName string\n\t// DirectoryPath in which seed file should be created\n\tDirectoryPath string\n\tData          io.Reader\n\tDatabase      string\n}\n\n// CreateSeedFile creates a .sql file according to the arguments\n// it'll return full filepath and an error if any.\nfunc CreateSeedFile(fs afero.Fs, opts CreateSeedOpts) (*string, error) {\n\tvar op internalerrors.Op = \"seed.CreateSeedFile\"\n\tif opts.Data == nil {\n\t\treturn nil, internalerrors.E(op, errors.New(\"no data provided\"))\n\t}\n\n\tconst fileExtension = \"sql\"\n\n\ttimestamp := strconv.FormatInt(time.Now().UnixNano()/int64(time.Millisecond), 10)\n\t// filename will be in format <timestamp>_<userProvidedSeedName>.sql\n\tfilenameWithTimeStamp := fmt.Sprintf(\n\t\t\"%s_%s.%s\",\n\t\ttimestamp,\n\t\topts.UserProvidedSeedName,\n\t\tfileExtension,\n\t)\n\tfullFilePath := filepath.Join(\n\t\tfilepath.Join(opts.DirectoryPath, opts.Database),\n\t\tfilenameWithTimeStamp,\n\t)\n\n\t// Write contents to file","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/seed/create.go#L16-L52","documentation":"CreateSeedFile refuses to create a seed file when opts.Data is nil, since it has no content to write. This is an argument-validation error: the caller must always supply a non-nil io.Reader (the data to seed) before a timestamped <timestamp>_<name>.sql file can be generated.","triggerScenarios":"Calling seed.CreateSeedFile(fs, CreateSeedOpts{...}) without setting the Data field, or passing a nil *os.File / nil reader as the export source.","commonSituations":"Building a seed programmatically and forgetting the Data field, refactoring away the file-reading code that used to populate Data, or a nil pointer from a previous failed operation being forwarded.","solutions":["Always set CreateSeedOpts.Data to a non-nil io.Reader (e.g. the result of ExportDatadump or the open source file)","Check for nil before calling and fail early with a clearer message upstream","If Data comes from another step, verify that step succeeded before creating the seed file"],"exampleFix":"// before\nopts := seed.CreateSeedOpts{ SeedName: \"demo\" }\npath, err := seed.CreateSeedFile(fs, opts)\n\n// after\nopts := seed.CreateSeedOpts{ SeedName: \"demo\", Data: bytes.NewReader(sqlBytes) }\npath, err := seed.CreateSeedFile(fs, opts)","handlingStrategy":"validation","validationCode":"if opts.Data == nil {\n    return errors.New(\"refusing to create seed: opts.Data is required\")\n}\npath, err := seed.CreateSeedFile(fs, opts)","typeGuard":"func hasSeedData(opts seed.CreateSeedOpts) bool {\n    return opts.Data != nil\n}","tryCatchPattern":null,"preventionTips":["Construct CreateSeedOpts in one place with a mandatory Data assignment","Lint/test for nil Data in unit tests around seed creation"],"tags":["seeds","validation","nil-argument","hasura-cli"],"backgroundTag":"nil-required-argument","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}