{"record":{"id":"a08c12bfb4fdd6fe","repo":"gotify/server","slug":"migrate-config-requires-one-argument-the-path-to","errorCode":null,"errorMessage":"migrate-config requires one argument: the path to the old config.yml","messagePattern":"migrate-config requires one argument: the path to the old config\\.yml","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/migrate/migrate.go","lineNumber":76,"sourceCode":"\tPassStrength      *int\n\tUploadedImagesDir *string\n\tPluginsDir        *string\n\tRegistration      *bool\n\tOIDC              struct {\n\t\tEnabled       *bool\n\t\tIssuer        *string\n\t\tClientID      *string\n\t\tClientSecret  *string\n\t\tUsernameClaim *string\n\t\tRedirectURL   *string\n\t\tAutoRegister  *bool\n\t\tScopes        []string\n\t}\n}\n\nfunc Config(file string) (string, error) {\n\tif file == \"\" {\n\t\treturn \"\", errors.New(\"migrate-config requires one argument: the path to the old config.yml\")\n\t}\n\tdata, err := os.ReadFile(file)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot read config file %s: %w\", file, err)\n\t}\n\n\tvar migrated oldConfig\n\tif err := yaml.Unmarshal(data, &migrated); err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot parse config file %s: %w\", file, err)\n\t}\n\n\tcontent, err := godotenv.Marshal(buildEnv(migrated))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot render config: %w\", err)\n\t}\n\n\treturn content, nil\n}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/gotify/server/blob/14bfc256276775c425f988d621dccfe705de18ac/config/migrate/migrate.go#L58-L94","documentation":"Argument validation error from the migrate-config subcommand (config/migrate/migrate.go Config function). The command converts an old config.yml to the new format and requires exactly one argument — the path to the old config file. An empty path yields this error before any file I/O.","triggerScenarios":"Running the migrate-config command with no arguments; passing an empty string variable; wiring run/runMigrate so the path argument is dropped (e.g. flag parsing consumed it or os.Args indexing is wrong); tests calling Config(\"\").","commonSituations":"Forgetting the positional argument in a shell script or Docker CMD; the path stored in an unset env var; migrating run scripts where flags were reordered and the argument ended up empty.","solutions":["Invoke migrate-config with the path as its single argument, e.g. gitea migrate-config /etc/gitea-old/config.yml","Verify the variable holding the path is non-empty before invoking (e.g. [ -n \"$OLD_CONF\" ] || exit 1)","Check your flag parsing — ensure the positional path isn't swallowed by a flag definition","Quote paths with spaces so the shell passes them as one argument"],"exampleFix":"# before\ngitea migrate-config\n# after\ngitea migrate-config /etc/gitea/config.yml","handlingStrategy":"validation","validationCode":"if len(os.Args) < 2 || os.Args[1] == \"\" {\n    fmt.Fprintln(os.Stderr, \"usage: migrate-config <path-to-old-config.yml>\")\n    os.Exit(2)\n}\noldConf := os.Args[1]","typeGuard":"func hasConfigPathArg(args []string) bool {\n    return len(args) > 0 && args[0] != \"\"\n}","tryCatchPattern":"newConf, err := migrate.Config(oldConf)\nif err != nil {\n    if strings.Contains(err.Error(), \"requires one argument\") {\n        return fmt.Errorf(\"usage: migrate-config <path-to-old-config.yml>\")\n    }\n    return err\n}","preventionTips":["Always pass the old config path explicitly when invoking migrate-config","Guard scripts with a non-empty check on the path variable before calling the command","Quote paths containing spaces so they arrive as a single argument","Check flag parsing so positional arguments are not consumed as flag values"],"tags":["cli","config","migration","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"14bfc256276775c425f988d621dccfe705de18ac","analyzedAt":"2026-09-05T12:52:36.781Z","contentChangedAt":"2026-09-05T12:52:36.781Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}