{"record":{"id":"736acb052ebb974e","repo":"hasura/graphql-engine","slug":"cannot-set-sql-file-w","errorCode":null,"errorMessage":"cannot set sql file: %w","messagePattern":"cannot set sql file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/migrate_create.go","lineNumber":235,"sourceCode":"\tif o.fromServer {\n\t\to.sqlServer = true\n\t}\n\n\tvar migrateDrv *migrate.Migrate\n\t// disabling auto state migrations for migrate create command\n\to.EC.DisableAutoStateMigration = true\n\tif o.sqlServer || o.upSQLChanged || o.downSQLChanged {\n\t\tmigrateDrv, err = migrate.NewMigrate(o.EC, true, o.Source.Name, o.Source.Kind)\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(op, fmt.Errorf(\"cannot create migrate instance: %w\", err))\n\t\t}\n\t}\n\n\tif o.sqlFile != \"\" {\n\t\t// sql-file flag is set\n\t\terr := createOptions.SetSQLUpFromFile(o.sqlFile)\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(op, fmt.Errorf(\"cannot set sql file: %w\", err))\n\t\t}\n\t}\n\n\tif o.sqlServer {\n\t\tdata, err := migrateDrv.ExportSchemaDump(\n\t\t\to.includeSchemas,\n\t\t\to.excludeSchemas,\n\t\t\to.Source.Name,\n\t\t\to.Source.Kind,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(op, fmt.Errorf(\"cannot fetch schema dump: %w\", err))\n\t\t}\n\n\t\terr = createOptions.SetSQLUp(string(data))\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(\n\t\t\t\top,","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/migrate_create.go#L217-L253","documentation":"With --sql-file set, migrate create calls createOptions.SetSQLUpFromFile to read the given file into the up migration. This wraps file-read or content-validation failures (file missing, unreadable, or empty/invalid).","triggerScenarios":"`hasura migrate create X --sql-file path/to/file.sql` where the path doesn't exist, lacks read permission, or the file content fails validation (e.g. empty).","commonSituations":"Relative path resolved from a different working directory; typo in filename; file generated by a previous step that failed silently.","solutions":["Check the path exists and is readable: cat <path> from the same directory you run the CLI","Use an absolute path in scripts","Ensure the SQL file is non-empty and valid"],"exampleFix":"# before\nhasura migrate create fix-users --sql-file users.sql   # file actually in sql/users.sql\n# after\nhasura migrate create fix-users --sql-file sql/users.sql","handlingStrategy":"validation","validationCode":"test -s \"$SQLFILE\" || { echo \"sql file missing/empty\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for --sql-file in scripts","Assert non-empty generated SQL files before passing them"],"tags":["migrate-create","file-io","sql-file"],"backgroundTag":"input-file-read-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}