Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(web): make Google Drive "My Drive emails" optional for folder-only sync (#20528)

Denis Ermakov4ce76cbfb8ae
diff --git a/internal/syncer/connector/google_drive_test.go b/internal/syncer/connector/google_drive_test.go
index c4365cb9bb..bbbb5a42c0 100644
--- a/internal/syncer/connector/google_drive_test.go
+++ b/internal/syncer/connector/google_drive_test.go
@@ -277,6 +277,31 @@ func TestGoogleDriveSharedFolderScopesRecurse(t *testing.T) {
}
}
+// TestGoogleDriveSharedFolderOnlySkipsMyDrive verifies folder URLs without My Drive emails never widen to a whole My Drive.
+func TestGoogleDriveSharedFolderOnlySkipsMyDrive(t *testing.T) {
+ connector, err := NewGoogleDriveConnector(map[string]any{
+ "include_my_drives": true,
+ "my_drive_emails": "",
+ "shared_folder_urls": "https://drive.google.com/drive/folders/root-folder",
+ "credentials": map[string]any{
+ "google_primary_admin": "[email protected]",
+ "google_tokens": `{"client_id":"client","client_secret":"secret","refresh_token":"refresh"}`,
+ },
+ })
+ if err != nil {
+ t.Fatalf("NewGoogleDriveConnector failed: %v", err)
+ }
+
+ scopes, err := connector.buildScopes(t.Context())
+ if err != nil {
+ t.Fatalf("buildScopes failed: %v", err)
+ }
+ want := googleDriveScope{userEmail: "[email protected]", corpora: "folder", folderID: "root-folder"}
+ if len(scopes) != 1 || scopes[0] != want {
+ t.Fatalf("scopes = %+v, want only %+v", scopes, want)
+ }
+}
+
// TestGoogleDriveRateLimitRetries verifies rate limits do not truncate a scope.
func TestGoogleDriveRateLimitRetries(t *testing.T) {
connector, err := NewGoogleDriveConnector(map[string]any{
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index d1599a1e71..6eb89129cc 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -1689,7 +1689,7 @@ Example: Virtual Hosted Style`,
zoteroWebdavPasswordRequired:
'WebDAV password is required when attachment storage is WebDAV.',
google_driveMyDriveEmailsTip:
- 'Comma-separated emails whose "My Drive" contents should be indexed (include the primary admin).',
+ 'Optional. Comma-separated emails whose entire "My Drive" is indexed, in addition to the shared folders below. Leave empty to sync only those folders.',
google_driveSharedFoldersTip:
'Comma-separated Google Drive folder links to crawl.',
gmailPrimaryAdminTip:
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 967a742a85..3b5f531f22 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -1257,7 +1257,7 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 R
'请上传由 OAuth helper 或 Google Cloud Console 导出的 OAuth token JSON。也支持上传 “installed” 或 “web” 类型的 client_secret JSON。若为首次同步,将自动弹出浏览器完成 OAuth 授权流程;如果该 JSON 已包含 refresh token,将会被自动复用。',
google_drivePrimaryAdminTip: '拥有相应 Drive 访问权限的管理员邮箱。',
google_driveMyDriveEmailsTip:
- '需要索引其 “我的云端硬盘” 的邮箱,多个邮箱用逗号分隔(建议包含管理员)。',
+ '可选。将索引这些邮箱的整个 “我的云端硬盘”,并与下方的共享文件夹一并同步,多个邮箱用逗号分隔。留空则仅同步这些文件夹。',
google_driveSharedFoldersTip:
'需要同步的 Google Drive 文件夹链接,多个链接用逗号分隔。',
gmailPrimaryAdminTip:
diff --git a/web/src/pages/user-setting/data-source/constant/index.test.tsx b/web/src/pages/user-setting/data-source/constant/index.test.tsx
index cd5eaf7cbf..939b8e4e84 100644
--- a/web/src/pages/user-setting/data-source/constant/index.test.tsx
+++ b/web/src/pages/user-setting/data-source/constant/index.test.tsx
@@ -120,6 +120,24 @@ describe('Sitemap data source', () => {
});
});
+describe('Google Drive data source', () => {
+ it('lets a folder-only connector leave My Drive emails empty', () => {
+ const fields = getDataSourceFieldsWithExtras(
+ translate,
+ DataSourceKey.GOOGLE_DRIVE,
+ ) as Array<{ name: string; required?: boolean }>;
+ const myDriveEmails = fields.find(
+ (field) => field.name === 'config.my_drive_emails',
+ );
+ const sharedFolderUrls = fields.find(
+ (field) => field.name === 'config.shared_folder_urls',
+ );
+
+ expect(myDriveEmails?.required).toBe(false);
+ expect(sharedFolderUrls?.required).toBe(true);
+ });
+});
+
describe.each([
['MySQL', DataSourceKey.MYSQL],
['PostgreSQL', DataSourceKey.POSTGRESQL],
diff --git a/web/src/pages/user-setting/data-source/constant/index.tsx b/web/src/pages/user-setting/data-source/constant/index.tsx
index 763c17a561..89f036cc1e 100644
--- a/web/src/pages/user-setting/data-source/constant/index.tsx
+++ b/web/src/pages/user-setting/data-source/constant/index.tsx
@@ -1022,7 +1022,7 @@ const generateDataSourceFormFields = (t: TFunction) => ({
label: t('setting.dataSourceFieldMyDriveEmails'),
name: 'config.my_drive_emails',
type: FormFieldType.Text,
- required: true,
+ required: false,
tooltip: t('setting.google_driveMyDriveEmailsTip'),
},