diff --git a/apps/sim/lib/knowledge/__integration__/gitlab-group.integration.ts b/apps/sim/lib/knowledge/__integration__/gitlab-group.integration.ts index e0cbc42dc4c..375e6e7e43e 100644 --- a/apps/sim/lib/knowledge/__integration__/gitlab-group.integration.ts +++ b/apps/sim/lib/knowledge/__integration__/gitlab-group.integration.ts @@ -55,6 +55,7 @@ describe('GitLab group Search permission boundary', () => { let moved = false let failedDiscovery = false let added = false + let aliceLegacyResult: { documentId: string } | undefined let confidential = false let providerState = 'healthy' const checks: string[] = [] @@ -259,7 +260,7 @@ describe('GitLab group Search permission boundary', () => { boundary: 'Application use cases, real PostgreSQL and HTTP GitLab API fixture; TLS/SSRF transport substituted', checks, - passed: checks.length === 10, + passed: checks.length === 11, }, null, 2 @@ -433,9 +434,8 @@ describe('GitLab group Search permission boundary', () => { input: { organizationId: ids.organizationId, sourceId: legacyId }, }) expect(legacyRevision).toEqual({ revision: 1 }) - expect( - (await search(ids.aliceId, '11', undefined, 20, legacyId)).results.length - ).toBeGreaterThan(0) + aliceLegacyResult = (await search(ids.aliceId, '11', undefined, 20, legacyId)).results[0] + expect(aliceLegacyResult).toBeDefined() await replaceSearchSourcePermissions.execute({ principal: principal(ids.aliceId), input: { @@ -461,6 +461,33 @@ describe('GitLab group Search permission boundary', () => { checks.push('Atomic group refresh, revocation and existing source preservation') }) + it('leaves a source out of the searches of a reader its uploaded permissions no longer grant', async () => { + const accounts = async (userId: string) => + ( + await searchLiveKnowledge.execute({ + principal: principal(userId), + input: { + organizationId: ids.organizationId, + query: 'Atlas', + topK: 20, + filters: { source: 'gitlab' }, + resultSecretRegistry: new ResolvedSecretTraceRegistry(), + }, + }) + ).live?.accounts ?? [] + const alice = await accounts(ids.aliceId) + expect(alice.map((account) => account.accountId)).toEqual([`gitlab-source:${sourceId}`]) + expect(alice.every((account) => account.status === 'ok')).toBe(true) + expect(new Set((await accounts(ids.bobId)).map((account) => account.accountId))).toEqual( + new Set([`gitlab-source:${sourceId}`, `gitlab-source:${legacyId}`]) + ) + if (!aliceLegacyResult) throw new Error('Missing result found before revocation') + await expect(read(ids.aliceId, aliceLegacyResult.documentId)).rejects.toThrow( + 'This GitLab source is not available to your account.' + ) + checks.push('Sources granting the reader nothing are left out of their searches') + }) + it('preserves all grants on discovery failure and admits only one concurrent revision', async () => { failedDiscovery = true await expect(replace(2)).rejects.toMatchObject({ code: 'validation' }) diff --git a/apps/sim/lib/knowledge/connectors/permission-store.ts b/apps/sim/lib/knowledge/connectors/permission-store.ts index 88978b611ad..053c3feba25 100644 --- a/apps/sim/lib/knowledge/connectors/permission-store.ts +++ b/apps/sim/lib/knowledge/connectors/permission-store.ts @@ -37,6 +37,28 @@ export async function hasConnectorPermissionGrant( return Boolean(grant) } +/** The connectors among `connectorIds` that grant the reader's subject at least one collection. */ +export async function connectorsGrantingSubject( + connectorIds: readonly string[], + subjectToken: string +): Promise> { + const table = knowledgeConnectorPermissionGrant + const granted = new Set() + for (let offset = 0; offset < connectorIds.length; offset += 1000) { + const rows = await db + .selectDistinct({ connectorId: table.connectorId }) + .from(table) + .where( + and( + eq(table.subjectToken, subjectToken), + inArray(table.connectorId, connectorIds.slice(offset, offset + 1000)) + ) + ) + for (const row of rows) granted.add(row.connectorId) + } + return granted +} + /** Returns grants only for the bounded, canonical collections requested by the authorized caller. */ export async function readConnectorPermissionGrants( connectorId: string, diff --git a/apps/sim/lib/sim-search/live/README.md b/apps/sim/lib/sim-search/live/README.md index c91e5f7d98a..89a0609580b 100644 --- a/apps/sim/lib/sim-search/live/README.md +++ b/apps/sim/lib/sim-search/live/README.md @@ -7,7 +7,7 @@ This describes the live enterprise-search path. Credential Groups and ordinary k - **Sources** controls integration availability and account mode per integration. - **Member accounts** has no resource configuration. A member connects their own account under Integrations, and searches content that account can access through the provider API. A member can add several accounts of one provider, such as Google Drive in two tenants; each is searched and cited separately, and every search counts them toward its account limit. Old member resource filters are ignored and cleared when settings are saved. - **Service account** selects an admin-managed source. Its connection owns the resource settings; Sources does not duplicate them. GitHub uses one GitHub App source per repository instead of a single selected source. A member still connects their own account, except for GitLab. Search returns the intersection of the member's provider permissions and the source's current resource boundary. -- GitLab is always service-account mode. Slack and Jira currently support member mode only. +- GitLab is always service-account mode. A source whose uploaded CSV permissions grant the member no project is left out of their searches rather than reported unavailable on each one; a source checked against GitLab itself stays listed and its session decides. Slack and Jira currently support member mode only. - Removing a source integration prevents subsequent account resolution, searches, and reads. Paused, archived, deleted, wrong-organization, wrong-provider, and unapproved service sources cannot authorize search. The Search assistant exposes the dedicated search/read tools. It cannot discover or execute integration tools through `search_integration_tools`, `call_integration_tool`, or direct provider-tool names. The broader assistant outside Search retains its integration tools. @@ -58,7 +58,7 @@ Each event must exist under the source's delegated token, be in an allowed calen ### Slack -Member mode only. Search uses the connected user's Slack real-time search grant and provider search syntax. Date bounds are sent as numeric provider timestamps; date ordering selects keyword retrieval and timestamp sort, because Slack semantic retrieval uses relevance ordering. Channels, messages, direct messages, and files are limited by that grant and provider scopes; there is no admin channel filter in member mode. Missing required search scopes produce a reconnect status. Thread/file reads use the same connected identity. A file read downloads the full text of a canvas (HTML), text snippet, PDF or DOCX from `files.slack.com` only, using `url_private_download` when present (Slack redirects a PDF's `url_private` to a viewer on another domain), never a remote file's own URL (redirects are followed only within that host; a hop elsewhere, such as a sign-in page, keeps the preview), within the shared response-size limit; when Slack will not serve it, the read returns the `files.info` preview. Real-time Search returns at most 20 results a call and counts every page against the member's rate limit, so a search across every source reads one page; a Slack-scoped or native Slack search follows the cursor for up to three pages to fill its limit, and a later page that fails keeps the earlier pages and returns the unread cursor. +Member mode only. Search uses the connected user's Slack real-time search grant and provider search syntax. Date bounds are sent as numeric provider timestamps; date ordering selects keyword retrieval and timestamp sort, because Slack semantic retrieval uses relevance ordering. Channels, messages, direct messages, and files are limited by that grant and provider scopes; there is no admin channel filter in member mode. Missing required search scopes produce a reconnect status. Thread/file reads use the same connected identity. Real-time Search returns only a file's title for a file hit, so the hit names the file's type and size and whether a read returns its text. A file read downloads the full text of a canvas (HTML), text snippet, PDF or DOCX from `files.slack.com` only, using `url_private_download` when present (Slack redirects a PDF's `url_private` to a viewer on another domain), never a remote file's own URL (redirects are followed only within that host; a hop elsewhere, such as a sign-in page, keeps the preview), within the shared response-size limit; when Slack will not serve it, the read returns the `files.info` preview. Real-time Search returns at most 20 results a call and counts every page against the member's rate limit, so a search across every source reads one page; a Slack-scoped or native Slack search follows the cursor for up to three pages to fill its limit, and a later page that fails keeps the earlier pages and returns the unread cursor. ### GitHub diff --git a/apps/sim/lib/sim-search/live/accounts.test.ts b/apps/sim/lib/sim-search/live/accounts.test.ts index e0fd50ce09b..3b5f231c1a6 100644 --- a/apps/sim/lib/sim-search/live/accounts.test.ts +++ b/apps/sim/lib/sim-search/live/accounts.test.ts @@ -22,6 +22,7 @@ const hoisted = vi.hoisted(() => ({ })) vi.mock('@/lib/knowledge/search/integration-policy', () => knowledgeSearchIntegrationPolicyMock) vi.mock('@/lib/sim-search/live/gitlab-admin', () => ({ + isAdminGitLabAccountId: (accountId: string) => accountId.startsWith('gitlab-source:'), listAdminGitLabAccounts: hoisted.admin, resolveAdminGitLabAccount: hoisted.resolveAdmin, })) diff --git a/apps/sim/lib/sim-search/live/accounts.ts b/apps/sim/lib/sim-search/live/accounts.ts index 742700ff974..800cf45965a 100644 --- a/apps/sim/lib/sim-search/live/accounts.ts +++ b/apps/sim/lib/sim-search/live/accounts.ts @@ -20,6 +20,7 @@ import { resolveKnowledgeWorkspaceContext } from '@/lib/knowledge/application/co import { listOrganizationSearchApprovals } from '@/lib/knowledge/search/integration-policy' import { resolveCredentialTokenBundle } from '@/lib/oauth/credential-service' import { + isAdminGitLabAccountId, listAdminGitLabAccounts, resolveAdminGitLabAccount, } from '@/lib/sim-search/live/gitlab-admin' @@ -114,7 +115,7 @@ export async function listLiveAccounts( const [visible, mcp, admin] = await Promise.all([ workspaceContext ? filterWorkspaceAccountCredentials(workspaceContext, candidates) : candidates, listManagedMcpSearchAccounts(owner, userId, denied), - denied.has('gitlab') ? [] : listAdminGitLabAccounts(owner), + denied.has('gitlab') ? [] : listAdminGitLabAccounts(owner, userId), ]) if (visible.length === 0) return [...mcp, ...admin] // Metadata is fetched in one batch; a fresh binding check still precedes token resolution. @@ -162,7 +163,9 @@ export async function resolveLiveAccount( ) { const current = (await listLiveAccounts(owner, userId)).find((row) => row.id === accountId) if (!current) - throw new NativeSearchError('reconnect', 'This search connection is no longer available.') + throw isAdminGitLabAccountId(accountId) + ? new NativeSearchError('unavailable', 'This GitLab source is not available to your account.') + : new NativeSearchError('reconnect', 'This search connection is no longer available.') return resolveListedLiveAccount(owner, userId, current, signal) } diff --git a/apps/sim/lib/sim-search/live/gitlab-admin.test.ts b/apps/sim/lib/sim-search/live/gitlab-admin.test.ts index 0c3f73b1760..6fda990842d 100644 --- a/apps/sim/lib/sim-search/live/gitlab-admin.test.ts +++ b/apps/sim/lib/sim-search/live/gitlab-admin.test.ts @@ -1,10 +1,14 @@ +import { queueTableRows, schemaMock } from '@sim/testing' import { knowledgeAccessScopeMock, knowledgeAccessScopeMockFns, } from '@sim/testing/mocks/knowledge-access-scope.mock' import { beforeEach, describe, expect, it, vi } from 'vitest' import { groupToken } from '@/lib/knowledge/access/tokens' -import { createAdminGitLabSession } from '@/lib/sim-search/live/gitlab-admin' +import { + createAdminGitLabSession, + listAdminGitLabAccounts, +} from '@/lib/sim-search/live/gitlab-admin' import { gitLabCsvGroupToken, setGitLabCsvContext, @@ -19,6 +23,7 @@ const mocks = vi.hoisted(() => ({ search: vi.fn(), read: vi.fn(), grant: vi.fn(), + metadata: vi.fn(), })) vi.mock('@/lib/knowledge/access/scope', () => knowledgeAccessScopeMock) vi.mock('@/connectors/gitlab/permission-config/repository', () => ({ @@ -26,6 +31,7 @@ vi.mock('@/connectors/gitlab/permission-config/repository', () => ({ })) vi.mock('@/lib/knowledge/connectors/permission-store', () => ({ hasConnectorPermissionGrant: mocks.grant, + readConnectorPermissionMetadata: mocks.metadata, })) vi.mock('@/connectors/gitlab/permissions', () => ({ openGitLabDirectory: mocks.directory, @@ -236,3 +242,16 @@ describe('non-admin token and CSV permissions', () => { await expect(session()).rejects.toThrow('not available') }) }) + +describe('administrator-managed GitLab source listing', () => { + it('lists every source when its grants cannot be checked, leaving the session to refuse it', async () => { + queueTableRows(schemaMock.knowledgeConnector, [ + { id: 'source-a', config: source.config, encryptedApiKey: 'sealed' }, + ]) + mocks.metadata.mockRejectedValue(new Error('connection reset')) + + const accounts = await listAdminGitLabAccounts({ organizationId: 'org' }, 'reader') + + expect(accounts.map((account) => account.id)).toEqual(['gitlab-source:source-a']) + }) +}) diff --git a/apps/sim/lib/sim-search/live/gitlab-admin.ts b/apps/sim/lib/sim-search/live/gitlab-admin.ts index 8b95c69b2a6..e0e82df519b 100644 --- a/apps/sim/lib/sim-search/live/gitlab-admin.ts +++ b/apps/sim/lib/sim-search/live/gitlab-admin.ts @@ -1,5 +1,7 @@ import { db } from '@sim/db' import { knowledgeBase, knowledgeConnector } from '@sim/db/schema' +import { createLogger } from '@sim/logger' +import { describeError } from '@sim/utils/errors' import { and, eq, inArray, isNull } from 'drizzle-orm' import { decryptApiKey } from '@/lib/api-key/crypto' import { type ResourceOwner, resourceScopeFromOwner } from '@/lib/core/resource-scope' @@ -7,6 +9,7 @@ import { resourceScopeCondition } from '@/lib/core/resource-scope.server' import { createUserKnowledgeAccessProvider } from '@/lib/knowledge/access/scope' import { groupToken } from '@/lib/knowledge/access/tokens' import { + connectorsGrantingSubject, hasConnectorPermissionGrant, readConnectorPermissionGrants, readConnectorPermissionMetadata, @@ -44,6 +47,7 @@ import { } from '@/connectors/gitlab/permissions' import { normalizeGitLabHost } from '@/tools/gitlab/utils' +const logger = createLogger('SimSearchGitLabSources') const PREFIX = 'gitlab-source:' /** Canonical admin-managed sources only. Neither credentials nor indexed documents leave this module. */ @@ -72,20 +76,80 @@ async function sources(owner: ResourceOwner, connectorId?: string) { ) } -export async function listAdminGitLabAccounts(owner: ResourceOwner): Promise { - return (await sources(owner)).map((source) => ({ - id: `${PREFIX}${source.id}`, - provider: 'gitlab', - providerId: 'gitlab', - displayName: 'GitLab', - type: 'admin_source', - scopes: [], - })) +/** The viewer's own identity token, the subject every GitLab grant is checked against. */ +async function viewerToken(owner: ResourceOwner, userId: string): Promise { + const access = await createUserKnowledgeAccessProvider(userId, { + workspaceId: owner.workspaceId ?? undefined, + organizationId: owner.organizationId ?? undefined, + }).get() + return access.kind === 'user' ? access.tokens.find((value) => value.startsWith('u:')) : undefined +} + +function hasCsvPermissions(metadata: unknown): boolean { + try { + return readGitLabPermissionMetadata(metadata).mode === 'csv' + } catch { + return false + } +} + +/** The IDs of CSV-permission sources that grant the viewer no project. */ +async function ungrantedSources( + owner: ResourceOwner, + userId: string, + ids: string[] +): Promise> { + const csv = (await readConnectorPermissionMetadata(ids)) + .filter((row) => hasCsvPermissions(row.metadata)) + .map((row) => row.connectorId) + const own = csv.length ? await viewerToken(owner, userId) : undefined + if (!own) return new Set() + const granted = await connectorsGrantingSubject(csv, own) + return new Set(csv.filter((id) => !granted.has(id))) +} + +/** + * A source whose uploaded permissions grant the viewer nothing could never return a result, so it + * is left out rather than reported unavailable on every search. Sources that check permissions + * with GitLab, any whose stored permissions cannot be read, and every source when this check + * itself fails stay listed: their session decides. + */ +export async function listAdminGitLabAccounts( + owner: ResourceOwner, + userId: string +): Promise { + const rows = await sources(owner) + if (!rows.length) return [] + const hidden = await ungrantedSources( + owner, + userId, + rows.map((source) => source.id) + ).catch((error: unknown) => { + logger.warn('GitLab source grants could not be checked; listing every source', { + error: describeError(error), + }) + return new Set() + }) + return rows + .filter((source) => !hidden.has(source.id)) + .map((source) => ({ + id: `${PREFIX}${source.id}`, + provider: 'gitlab', + providerId: 'gitlab', + displayName: 'GitLab', + type: 'admin_source', + scopes: [], + })) +} + +/** Whether a live account ID names an administrator-managed GitLab source. */ +export function isAdminGitLabAccountId(accountId: string): boolean { + return accountId.startsWith(PREFIX) } export async function resolveAdminGitLabAccount(owner: ResourceOwner, account: LiveAccount) { const [source] = await sources(owner, account.id.slice(PREFIX.length)) - if (!account.id.startsWith(PREFIX) || !source?.encryptedApiKey) + if (!isAdminGitLabAccountId(account.id) || !source?.encryptedApiKey) throw new NativeSearchError( 'unavailable', 'Ask an organization admin to check the GitLab connection.' @@ -129,17 +193,7 @@ interface GitLabSessionInput { } export async function createAdminGitLabSession(input: GitLabSessionInput) { - const { owner, userId } = input - const access = await createUserKnowledgeAccessProvider(userId, { - workspaceId: owner.workspaceId ?? undefined, - organizationId: owner.organizationId ?? undefined, - }).get() - if (access.kind !== 'user') - throw new NativeSearchError( - 'unavailable', - 'GitLab search requires a verified organization identity.' - ) - const own = access.tokens.find((value) => value.startsWith('u:')) + const own = await viewerToken(input.owner, input.userId) if (!own) throw new NativeSearchError( 'unavailable', diff --git a/apps/sim/lib/sim-search/live/providers.test.ts b/apps/sim/lib/sim-search/live/providers.test.ts index c6bc58d8d76..fd4d8498fd2 100644 --- a/apps/sim/lib/sim-search/live/providers.test.ts +++ b/apps/sim/lib/sim-search/live/providers.test.ts @@ -195,6 +195,69 @@ describe('native search endpoints', () => { }) }) +describe('Slack file hits', () => { + const fileHits = async (files: Record[]) => { + const api = client() + api.json.mockResolvedValue({ ok: true, results: { files } }) + const { documents } = await searchSlack(api, { + ...input, + scopes: ['search:read.public', 'search:read.files'], + }) + return documents.map(({ content }) => content) + } + const hit = (fields: Record) => ({ + file_id: 'F1', + title: 'Q3 plan', + content: 'Q3 plan', + permalink: 'https://team.slack.com/files/U1/F1', + ...fields, + }) + + it('says what each file is and whether a read returns its text, instead of echoing its title', async () => { + expect( + await fileHits([ + hit({ file_type: 'application/pdf', size: 245760 }), + hit({ file_type: 'application/vnd.slack-docs' }), + hit({ file_type: 'text/csv; charset=utf-8' }), + hit({ file_type: 'image/png' }), + hit({ file_type: 'application/vnd.slack-list' }), + ]) + ).toEqual([ + 'PDF, 240 KB. Reading it returns its full text.', + 'Canvas. Reading it returns its full text.', + 'CSV. Reading it returns its full text.', + 'Image. Its contents cannot be read here; open the source.', + 'List. Its contents cannot be read here; open the source.', + ]) + }) + + it('keeps text Slack returns beyond the title and describes a file of unknown type plainly', async () => { + expect( + await fileHits([ + hit({ file_type: 'application/pdf', content: 'Revenue grew 12% in Q3' }), + hit({ content: '' }), + hit({ file_type: 'application/x-unknown', title: 'Plan v2.1 final', content: '' }), + ]) + ).toEqual([ + 'PDF. Reading it returns its full text.\nRevenue grew 12% in Q3', + 'File. Its contents cannot be read here; open the source.', + 'File. Its contents cannot be read here; open the source.', + ]) + }) + + it('offers no full text for a file above the read limit or an empty one', async () => { + expect( + await fileHits([ + hit({ file_type: 'application/pdf', size: 5 * 1024 * 1024 }), + hit({ file_type: 'text/plain', size: 0 }), + ]) + ).toEqual([ + 'PDF, 5 MB. Too large to read in full here; open the source.', + 'Text, 0 Bytes. The file is empty.', + ]) + }) +}) + describe('Slack RTS pages', () => { const scopes = ['search:read.public'] const slackPage = (first: number, count: number, nextCursor?: string) => ({ diff --git a/apps/sim/lib/sim-search/live/slack.ts b/apps/sim/lib/sim-search/live/slack.ts index c8502dd83f6..69b1b41a5cc 100644 --- a/apps/sim/lib/sim-search/live/slack.ts +++ b/apps/sim/lib/sim-search/live/slack.ts @@ -27,6 +27,9 @@ import type { NativePage, NativeSearchInput, } from '@/lib/sim-search/live/types' +import { formatFileSize } from '@/lib/uploads/utils/file' +import { normalizeMimeType } from '@/lib/uploads/utils/mime' +import { fileBrowserTypeLabel } from '@/lib/workspace-files/browser' /** Slack's own label for an account whose name is unavailable. */ const SLACK_MEMBER = 'Slack member' @@ -324,7 +327,7 @@ async function searchSlackPage( kind: 'file', title: string(file.title), url: string(file.permalink), - content: slackPlainText(string(file.content), users), + content: slackFileHitContent(file, users), author: string(file.author_name), ...(Number.isFinite(updated) && updated > 0 ? { modifiedAt: new Date(updated).toISOString() } @@ -352,7 +355,7 @@ type SlackFileFormat = 'html' | 'plain' | 'pdf' | 'docx' /** How a file's full text can be read, or undefined when Slack offers only its preview. */ function slackFileFormat(file: Record): SlackFileFormat | undefined { - const mimetype = string(file.mimetype).split(';')[0].trim().toLowerCase() + const mimetype = normalizeMimeType(string(file.mimetype)) if ( string(file.filetype) === 'quip' || mimetype === 'application/vnd.slack-docs' || @@ -363,6 +366,50 @@ function slackFileFormat(file: Record): SlackFileFormat | undef return documentExtension(mimetype) } +/** Whether a read downloads a file of this size; an unreported size is tried and capped while reading. */ +function withinDownloadLimit(format: SlackFileFormat, size: unknown): boolean { + return !(Number(size) > MAX_FILE_DOWNLOAD_BYTES[format]) +} + +const SLACK_FILE_LABELS: Readonly> = { + 'application/vnd.slack-docs': 'Canvas', + 'application/vnd.slack-list': 'List', +} + +/** The shared label for a known type; a title is not a filename, so it never supplies one. */ +function knownFileLabel(mimetype: string): string { + const label = fileBrowserTypeLabel(mimetype, '') + return label && label !== mimetype ? label : 'File' +} + +/** + * Slack search returns only a file's title, repeated as its content. A hit says what the file is + * and whether reading it returns its text, so a reader can tell which files to open. + */ +function slackFileHitContent(file: Record, users: Map): string { + const mimetype = normalizeMimeType(string(file.file_type)) + const summary = [ + SLACK_FILE_LABELS[mimetype] ?? knownFileLabel(mimetype), + typeof file.size === 'number' && file.size >= 0 + ? formatFileSize(file.size, { includeBytes: true }) + : '', + ] + .filter(Boolean) + .join(', ') + const format = slackFileFormat({ mimetype }) + const reading = !format + ? 'Its contents cannot be read here; open the source.' + : file.size === 0 + ? 'The file is empty.' + : withinDownloadLimit(format, file.size) + ? 'Reading it returns its full text.' + : 'Too large to read in full here; open the source.' + const text = slackPlainText(string(file.content), users) + return [`${summary}. ${reading}`, text === string(file.title) ? '' : text] + .filter(Boolean) + .join('\n') +} + const BYTE_ORDER_MARKS = [ [[0xef, 0xbb, 0xbf], 'utf-8'], [[0xff, 0xfe], 'utf-16le'], @@ -400,7 +447,7 @@ async function slackFileText( signal?: AbortSignal ): Promise<{ text: string } | { unavailable?: string }> { const format = slackFileFormat(file) - if (!format || Number(file.size) > MAX_FILE_DOWNLOAD_BYTES[format]) return {} + if (!format || !withinDownloadLimit(format, file.size)) return {} const source = slackFileDownloadUrl(file) if (!source) return {} const timeout = AbortSignal.timeout(FILE_DOWNLOAD_TIMEOUT_MS)