{"record":{"id":"94a1e36a1f423448","repo":"AlistGo/alist","slug":"sub-id-is-required-when-exporting-lark-type-q-as","errorCode":null,"errorMessage":"sub_id is required when exporting lark type %q as %q","messagePattern":"sub_id is required when exporting lark type %q as %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/lark/other.go","lineNumber":126,"sourceCode":"\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).\n\t\tFileName(larkExportBaseName(obj.GetName()))\n\tif subID != \"\" {\n\t\tbuilder.SubId(subID)\n\t}\n\texportTask := builder.Build()\n\tresp, err := doDrive(ctx, c, func(opts ...larkcore.RequestOptionFunc) (*larkdrive.CreateExportTaskResp, error) {\n\t\treturn c.client.Drive.V1.ExportTask.Create(ctx,\n\t\t\tlarkdrive.NewCreateExportTaskReqBuilder().ExportTask(exportTask).Build(), opts...)\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/lark/other.go#L108-L144","documentation":"Validation error in the Lark driver's createExportTask: larkExportFormatRequiresSubID returns true for a docType/format combination (a secondary sub-document must be identified) but the request's SubID field is empty after trimming. Lark's export API requires a sub_id for those combinations to know which sub-sheet/sub-document to export.","triggerScenarios":"Creating an export task for a format flagged as requiring a sub-document id (per the internal format/subID matrix) while omitting req.SubID or sending only whitespace.","commonSituations":"Callers reuse a create request built for a simple doc and forget the sub-document selector when exporting sheets/bitable; frontend forms that do not expose a sub-id field; copying an example payload that lacks sub_id.","solutions":["Populate req.SubID with the id of the sub-document/sub-sheet to export (trimmed of whitespace).","List the object's children/sub-documents first to obtain valid sub ids before creating the task.","If you did not intend a sub-id-requiring format, switch the format to one that does not require it (e.g. pdf/docx for docs).","Update OpenList — the sub-id requirement matrix may have been refined upstream."],"exampleFix":"// before\nreq := larkExportCreateReq{Format: \"csv\"} // needs SubID -> error\n// after\nreq := larkExportCreateReq{Format: \"csv\", SubID: \"sheetId_abc123\"}","handlingStrategy":"validation","validationCode":"if larkExportFormatRequiresSubID(docType, format) && strings.TrimSpace(req.SubID) == \"\" {\n    return errors.New(\"fill SubID before creating this export task\")\n}\n// enumerate sub-documents first to obtain ids","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"sub_id is required\") {\n    // fetch sub-document list, populate SubID, retry once\n}","preventionTips":["Always enumerate sub-documents when exporting sheets/bitable to csv.","Treat empty SubID as an incomplete request in form validation.","Trim sub_id input; whitespace-only values are treated as missing."],"tags":["lark","feishu","export","validation","sub-id","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}