AlistGo/alist · error
pattern must contain one name token: {name}
Error message
pattern must contain one name token: {name} What it means
parseNameToken reports this when the chunk name format pattern contains zero occurrences of the {name} token. The token is mandatory because the driver must embed the original file's base name into every chunk file name to be able to reassemble and identify the file.
Source
Thrown at drivers/chunker/util.go:126
d.nameRegexp = regexp.MustCompile(strRegex)
fmtDigits := "%d"
if chunkWidth > 0 {
fmtDigits = fmt.Sprintf("%%0%dd", chunkWidth)
}
d.dataNameFmt = strings.ReplaceAll(beforeName, "%", "%%") +
"%s" +
strings.ReplaceAll(between, "%", "%%") +
fmtDigits +
strings.ReplaceAll(afterChunk, "%", "%%")
return nil
}
func parseNameToken(pattern string) (start, end int, err error) {
nameMagicCount := strings.Count(pattern, "{name}")
switch nameMagicCount {
case 0:
return 0, 0, errors.New("pattern must contain one name token: {name}")
case 1:
default:
return 0, 0, errors.New("pattern must contain exactly one name token: {name}")
}
start = strings.Index(pattern, "{name}")
return start, start + len("{name}"), nil
}
func parseChunkToken(pattern string) (start, end, width int, err error) {
chunkMatches := chunkTokenRegexp.FindAllStringSubmatchIndex(pattern, -1)
switch len(chunkMatches) {
case 0:
return 0, 0, 0, errors.New("pattern must contain one chunk token: {chunk} or {chunk:N}")
case 1:
default:
return 0, 0, 0, errors.New("pattern must contain exactly one chunk token: {chunk} or {chunk:N}")
}
match := chunkMatches[0]View on GitHub (pinned to 843d9dc814)
Solutions
- Add the {name} token to the pattern, e.g. '{name}_{chunk:03}'
- Check for typos such as {filename}, {file}, or {Name} — only the exact literal {name} is recognized
Example fix
// before
chunk_name_format: chunk_{chunk:03}
// after
chunk_name_format: {name}_chunk_{chunk:03} Defensive patterns
Strategy: validation
Validate before calling
if strings.Count(f, "{name}") != 1 {
return fmt.Errorf("chunk name format must contain exactly one {name} token: %q", f)
} Prevention
- Treat {name} as a required token in templates surfaced to users
- Reject configs early instead of letting storage Init fail at runtime
When it happens
Trigger: Configuring chunk_name_format as 'part_{chunk:03}' or 'file-{chunk}' — any pattern with a {chunk} token but no {name}. Thrown from setChunkNameFormat during Init, so the storage fails to come online.
Common situations: Users trying to shorten chunk file names; templates written from memory that omit {name}; misunderstanding that {name} is required, not optional.
Related errors
- directory separator prohibited
- name token must come before chunk token
- pattern must contain exactly one name token: {name}
- pattern must contain one chunk token: {chunk} or {chunk:N}
- pattern must contain exactly one chunk token: {chunk} or {ch
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/42cb2e822c3b15fa.
Report an issue: GitHub.