{"record":{"id":"c287cae370ec8e33","repo":"AlistGo/alist","slug":"lark-file-token-not-found","errorCode":null,"errorMessage":"lark file token not found","messagePattern":"lark file token not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/lark/other.go","lineNumber":114,"sourceCode":"\t\treturn nil, fmt.Errorf(\"unsupported lark method: %s\", args.Method)\n\t}\n}\n\nfunc decodeOtherData(data interface{}, v interface{}) error {\n\tb, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn errors.WithMessage(err, \"failed to encode request data\")\n\t}\n\tif err = json.Unmarshal(b, v); err != nil {\n\t\treturn errors.WithMessage(err, \"failed to decode request data\")\n\t}\n\treturn nil\n}\n\nfunc (c *Lark) createExportTask(ctx context.Context, obj model.Obj, req larkExportCreateReq) (*LarkExportCreateResp, error) {\n\ttoken, ok := c.getObjToken(ctx, obj.GetPath())\n\tif !ok {\n\t\treturn nil, errors.WithStack(errors.New(\"lark file token not found\"))\n\t}\n\tdocType, err := larkExportType(obj.GetName())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tformat := strings.ToLower(strings.TrimSpace(req.Format))\n\tif !larkExportFormatAllowed(docType, format) {\n\t\treturn nil, fmt.Errorf(\"unsupported export format %q for lark type %q\", format, docType)\n\t}\n\tsubID := strings.TrimSpace(req.SubID)\n\tif larkExportFormatRequiresSubID(docType, format) && subID == \"\" {\n\t\treturn nil, fmt.Errorf(\"sub_id is required when exporting lark type %q as %q\", docType, format)\n\t}\n\n\tbuilder := larkdrive.NewExportTaskBuilder().\n\t\tToken(token).\n\t\tType(docType).\n\t\tFileExtension(format).","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/lark/other.go#L96-L132","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, ok := c.getObjToken(ctx, obj.GetPath()); !ok {\n\t// force cache miss: tokens may be stale after renames\n\tobjTokenCache.Del(obj.GetPath())\n}","typeGuard":"func (c *Lark) hasObjToken(ctx context.Context, p string) bool {\n\t_, ok := c.getObjToken(ctx, p)\n\treturn ok\n}","tryCatchPattern":"resp, err := c.createExportTask(ctx, obj, req)\nif err != nil && strings.Contains(err.Error(), \"lark file token not found\") {\n\t// path resolution failed: refresh listing once, then fail with context\n\treturn nil, fmt.Errorf(\"cannot resolve %s to a lark token (moved/deleted?): %w\", obj.GetPath(), err)\n}","preventionTips":["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"],"tags":["lark","feishu","export","token-resolution","driver"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}