AlistGo/alist · error
pattern must contain exactly one name token: {name}
Error message
pattern must contain exactly one name token: {name} What it means
parseNameToken reports this when the chunk name format contains two or more {name} tokens. Exactly one is required: the driver builds a printf format string (%s for the name) and a regexp to reverse-match chunk files, and multiple name tokens are ambiguous.
Source
Thrown at drivers/chunker/util.go:129
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]
start = match[0]
end = match[1]
if match[2] >= 0 && match[3] >= 0 {View on GitHub (pinned to 843d9dc814)
Solutions
- Leave exactly one {name} token in the pattern
- If you wanted name and extension split, note that {name} already denotes the full base name including extension — use it once
Example fix
// before
chunk_name_format: {name}.{name}_{chunk:03}
// after
chunk_name_format: {name}_{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
- Use strings.Count rather than Index when validating, so duplicates are caught
- Run the driver's own setChunkNameFormat in a dry-run/test before deploying config
When it happens
Trigger: A chunk_name_format like '{name}-{name}_{chunk:03}' or '{name}/{name}_{chunk}' (after removing separators). Raised in setChunkNameFormat at init time.
Common situations: Copy-paste concatenation of templates; attempting to simulate name+extension separately (e.g. '{name}.{name}'); editing an existing pattern and accidentally duplicating the token.
Related errors
- directory separator prohibited
- name token must come before chunk token
- pattern must contain 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/97e921f82c6ab3cc.
Report an issue: GitHub.