AlistGo/alist · error
mode error
Error message
mode error
What it means
Returned by IPFS driver List when the configured Mode is none of "ipfs", "ipns", or "mfs" (or, in the outer branch, when path resolution reaches the default case). The driver cannot decide how to interpret the root path without a valid mode, so listing aborts before any shell call.
Source
Thrown at drivers/ipfs_api/driver.go:64
cid := dir.GetID()
if cid != "" {
ipfsPath = path.Join("/ipfs", cid)
} else {
// 可能出现ipns dns解析失败的情况,需要重复获取cid,其他情况应该不会出错
ipfsPath = dir.GetPath()
switch d.Mode {
case "ipfs":
ipfsPath = path.Join("/ipfs", ipfsPath)
case "ipns":
ipfsPath = path.Join("/ipns", ipfsPath)
case "mfs":
fileStat, err := d.sh.FilesStat(ctx, ipfsPath)
if err != nil {
return nil, err
}
ipfsPath = path.Join("/ipfs", fileStat.Hash)
default:
return nil, fmt.Errorf("mode error")
}
}
dirs, err := d.sh.List(ipfsPath)
if err != nil {
return nil, err
}
objlist := []model.Obj{}
for _, file := range dirs {
objlist = append(objlist, &model.Object{ID: file.Hash, Name: file.Name, Size: int64(file.Size), IsFolder: file.Type == 1})
}
return objlist, nil
}
func (d *IPFS) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
gateurl := d.gateURL.JoinPath("/ipfs/", file.GetID())
gateurl.RawQuery = "filename=" + url.QueryEscape(file.GetName())View on GitHub (pinned to 843d9dc814)
Solutions
- Set Mode to exactly one of "ipfs", "ipns", or "mfs" (lowercase) in the driver addition config.
- Validate mode at driver-init time (fail fast with a clear message listing valid values).
- If using the UI, reselect the mode from the dropdown rather than typing it.
Example fix
// before (config)
{ "mode": "IPFS" }
// after
{ "mode": "ipfs" } Defensive patterns
Strategy: validation
Validate before calling
var validModes = map[string]bool{"ipfs": true, "ipns": true, "mfs": true}
if !validModes[d.Addition.Mode] {
return fmt.Errorf("invalid mode %q, must be ipfs, ipns, or mfs", d.Addition.Mode)
} Type guard
func isValidIPFSMode(mode string) bool {
switch mode {
case "ipfs", "ipns", "mfs":
return true
}
return false
} Prevention
- Validate mode at storage-save time in the UI
- Use dropdowns, not free text, for mode fields
- Fail fast in Init rather than per-operation
When it happens
Trigger: Typo in the driver's mode config field (e.g. "IPFS", "mfs ", "msf"); config written by an older schema using different mode names; empty Mode reaching the default branch.
Common situations: Hand-edited config JSON with casing errors; UI dropdown value mismatch after a driver update; default value not applied when config was created programmatically.
Related errors
- remote_path is required
- chunk_size must be positive
- owner and repo are required
- committer email is required
- committer name is required
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/b7cc9942cef8cf8f.
Report an issue: GitHub.