{"record":{"id":"cf2e286e99566e20","repo":"duplicati/duplicati","slug":"prefixcannotcontainhyphens","errorCode":"PrefixCannotContainHyphens","errorMessage":"The prefix cannot contain hyphens (-)","messagePattern":"The prefix cannot contain hyphens \\(-\\)","errorType":"exception","errorClass":"UserInformationException","httpStatus":null,"severity":"error","filePath":"Duplicati/Library/Main/Controller.cs","lineNumber":978,"sourceCode":"            if (m_options.KeepVersions > 0)\n            {\n                selectedRetentionOptions.Add(\"keep-versions\");\n            }\n\n            if (m_options.RetentionPolicy.Any())\n            {\n                selectedRetentionOptions.Add(\"retention-policy\");\n            }\n\n            if (selectedRetentionOptions.Count() > 1)\n            {\n                throw new UserInformationException(string.Format(\"Setting multiple retention options ({0}) is not permitted\",\n                    string.Join(\", \", selectedRetentionOptions.Select(x => \"--\" + x))), \"MultipleRetentionOptionsNotSupported\");\n            }\n\n            // Check Prefix\n            if (!string.IsNullOrWhiteSpace(m_options.Prefix) && m_options.Prefix.Contains(\"-\"))\n                throw new UserInformationException(\"The prefix cannot contain hyphens (-)\", \"PrefixCannotContainHyphens\");\n\n            if (m_options.VolumeSize < m_options.Blocksize * 2)\n                throw new UserInformationException(\"The volume size must be at least twice the block size\", \"VolumeSizeTooSmall\");\n\n            //Check validity of retention-policy option value\n            try\n            {\n                foreach (var configEntry in m_options.RetentionPolicy)\n                {\n                    if (!configEntry.IsKeepAllVersions() && !configEntry.IsUnlimtedTimeframe() &&\n                        configEntry.Interval >= configEntry.Timeframe)\n                    {\n                        throw new Interface.UserInformationException(\"An interval cannot be bigger than the timeframe it is in\", \"IntervalCannotBeBiggerThanTimeFrame\");\n                    }\n                }\n            }\n            catch (Exception e) // simply reading the option value might also result in an exception due to incorrect formatting\n            {","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/duplicati/duplicati/blob/3f348be3e33f5d72d414e3ad55839c2ba34dda67/Duplicati/Library/Main/Controller.cs#L960-L996","documentation":"Thrown by Controller.ValidateOptions when the backup --prefix is non-empty and contains a hyphen ('-'). Prefixes are used to build dblock/dlist/dindex filenames; hyphens would collide with Duplicati's internal filename delimiter parsing.","triggerScenarios":"Setting --prefix to a value containing '-' while the prefix is not blank.","commonSituations":"Using a descriptive prefix like 'my-backup'; appending a date or environment tag with hyphens; migrating from a tool that allowed hyphens.","solutions":["Replace hyphens in the prefix with underscores or remove them.","Leave --prefix unset to use the default prefix.","If renaming, remember the prefix must match existing remote files or a new backup chain starts."],"exampleFix":"// before: hyphen in prefix\n--prefix=my-backup\n\n// after: underscore instead\n--prefix=my_backup","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrWhiteSpace(m_options.Prefix) && m_options.Prefix.Contains('-'))\n    throw new ArgumentException(\"Prefix must not contain hyphens\");","typeGuard":null,"tryCatchPattern":"try { controller.BackupAsync(...); }\ncatch (UserInformationException ex) when (ex.HelpID == \"PrefixCannotContainHyphens\")\n{ /* sanitize prefix and retry */ }","preventionTips":["Use underscores or alphanumerics in prefixes.","Validate generated prefixes in config templates."],"tags":["configuration","validation","naming"],"backgroundTag":null,"analyzedSha":"3f348be3e33f5d72d414e3ad55839c2ba34dda67","analyzedAt":"2026-08-13T16:48:27.008Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}