AlistGo/alist · error
lark file token not found
Error message
lark file token not found
What it means
createExportTask resolves the object's Lark token via getObjToken(obj.GetPath()); the second return is false when the token cannot be found — the path-to-token cache misses and recursive directory listing finds no entry whose name matches (see util.go:18-53). Export needs a concrete file token, so it aborts with this stacked error.
Source
Thrown at drivers/lark/other.go:114
return nil, fmt.Errorf("unsupported lark method: %s", args.Method)
}
}
func decodeOtherData(data interface{}, v interface{}) error {
b, err := json.Marshal(data)
if err != nil {
return errors.WithMessage(err, "failed to encode request data")
}
if err = json.Unmarshal(b, v); err != nil {
return errors.WithMessage(err, "failed to decode request data")
}
return nil
}
func (c *Lark) createExportTask(ctx context.Context, obj model.Obj, req larkExportCreateReq) (*LarkExportCreateResp, error) {
token, ok := c.getObjToken(ctx, obj.GetPath())
if !ok {
return nil, errors.WithStack(errors.New("lark file token not found"))
}
docType, err := larkExportType(obj.GetName())
if err != nil {
return nil, err
}
format := strings.ToLower(strings.TrimSpace(req.Format))
if !larkExportFormatAllowed(docType, format) {
return nil, fmt.Errorf("unsupported export format %q for lark type %q", format, docType)
}
subID := strings.TrimSpace(req.SubID)
if larkExportFormatRequiresSubID(docType, format) && subID == "" {
return nil, fmt.Errorf("sub_id is required when exporting lark type %q as %q", docType, format)
}
builder := larkdrive.NewExportTaskBuilder().
Token(token).
Type(docType).
FileExtension(format).View on GitHub (pinned to 843d9dc814)
Solutions
- Refresh the directory listing and retry the export on the current path
- Confirm the file still exists and the app has access to it in Feishu
- Check server logs for the 'failed to list files' error that accompanies a listFiles failure
- Retry after the objTokenCache TTL expires so tokens are re-resolved
Defensive patterns
Strategy: retry
Validate before calling
if _, ok := c.getObjToken(ctx, obj.GetPath()); !ok {
// force cache miss: tokens may be stale after renames
objTokenCache.Del(obj.GetPath())
} Type guard
func (c *Lark) hasObjToken(ctx context.Context, p string) bool {
_, ok := c.getObjToken(ctx, p)
return ok
} Try / catch
resp, err := c.createExportTask(ctx, obj, req)
if err != nil && strings.Contains(err.Error(), "lark file token not found") {
// path resolution failed: refresh listing once, then fail with context
return nil, fmt.Errorf("cannot resolve %s to a lark token (moved/deleted?): %w", obj.GetPath(), err)
} Prevention
- Refresh the parent listing before export when objects change often
- Watch logs for 'failed to list files' — the underlying listFiles error is swallowed by getObjToken
When it happens
Trigger: Exporting an object whose path no longer resolves: file renamed/deleted since listing, path contains characters defeated by trimLarkDisplayExt mismatch, listFiles failed (its error is only logged, not propagated), or the object is a root path with no rootFolderToken.
Common situations: Stale cached listing in the UI pointing at a moved/deleted doc; Lark doc display-extension suffixes (e.g. .docx appended by alist) not matching; listFiles intermittent failure swallowed as ok=false.
Related errors
- lark export task response missing ticket
- ticket is required
- lark refresh token expired
- lark refresh token response missing access token
- failed to get download link
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/c287cae370ec8e33.
Report an issue: GitHub.