Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): clarify Upload v2 compatibility limits

Josuéb1c26b6e42e9
diff --git a/desktop-app/src/__tests__/appService.gfs.test.ts b/desktop-app/src/__tests__/appService.gfs.test.ts
index 52576d0aa..8a941f997 100644
--- a/desktop-app/src/__tests__/appService.gfs.test.ts
+++ b/desktop-app/src/__tests__/appService.gfs.test.ts
@@ -403,7 +403,7 @@ describe('AppService GFS upload security scope', () => {
await expect(
service.startGfsFileUpload('parent-rid', 'oversized-legacy.bin', filePath, 'main')
- ).rejects.toThrow(`legacy GFS is limited to ${16 * 1024 * 1024} bytes`)
+ ).rejects.toThrow('legacy GFS is limited to 16 MiB')
expect(service.gfsClient.createResource).not.toHaveBeenCalled()
expect(service.gfsClient.replaceFile).not.toHaveBeenCalled()
} finally {
diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.ts
index b221b8d33..dfff26e7b 100644
--- a/desktop-app/src/appService.ts
+++ b/desktop-app/src/appService.ts
@@ -23,6 +23,7 @@ import {
type DesktopUploadInput,
type DesktopUploadSession,
type DesktopUploadTransport,
+ formatGfsUploadLimit,
} from './gfs/upload.js'
import { GfsClient, type GfsResourceView, parseSubjectKey } from './gfs/uriHandler.js'
import { ApiError, requestJson, withTimeout } from './httpClient.js'
@@ -326,7 +327,7 @@ async function readBoundedLegacyFile(handle: fs.promises.FileHandle): Promise<Bu
totalBytes += bytesRead
if (totalBytes > LEGACY_GFS_MAX_FILE_BYTES) {
throw new Error(
- `This writer does not advertise resumable uploads; legacy GFS is limited to ${LEGACY_GFS_MAX_FILE_BYTES} bytes.`
+ `This writer does not advertise resumable uploads; legacy GFS is limited to ${formatGfsUploadLimit(LEGACY_GFS_MAX_FILE_BYTES)}.`
)
}
chunks.push(chunk.subarray(0, bytesRead))
@@ -350,7 +351,7 @@ export async function legacyEncodedFile(filePath: string): Promise<string> {
if (!info.isFile()) throw new Error('selected upload path is not a regular file')
if (info.size > LEGACY_GFS_MAX_FILE_BYTES) {
throw new Error(
- `This writer does not advertise resumable uploads; legacy GFS is limited to ${LEGACY_GFS_MAX_FILE_BYTES} bytes.`
+ `This writer does not advertise resumable uploads; legacy GFS is limited to ${formatGfsUploadLimit(LEGACY_GFS_MAX_FILE_BYTES)}.`
)
}
diff --git a/desktop-app/src/gfs/upload.test.ts b/desktop-app/src/gfs/upload.test.ts
index 8625d9b90..b154a6f8c 100644
--- a/desktop-app/src/gfs/upload.test.ts
+++ b/desktop-app/src/gfs/upload.test.ts
@@ -5,7 +5,9 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import {
DesktopGfsUploadJob,
+ DesktopUploadCapabilityError,
allowsLegacyCapabilityFallback,
+ formatGfsUploadLimit,
isAmbiguousUploadStatus,
isRetryableUploadStatus,
normalizeInstabilityFailureThreshold,
@@ -30,6 +32,13 @@ describe('desktop GFS indexed uploader', () => {
expect(normalizeUploadProductMaxBytes(undefined)).toBe(209_715_200)
})
+ it('formats Upload v2 display values without becoming product policy authority', () => {
+ expect(formatGfsUploadLimit(300 * 1024 * 1024)).toBe('300 MiB')
+ expect(formatGfsUploadLimit(16 * 1024 * 1024)).toBe('16 MiB')
+ expect(formatGfsUploadLimit(1024 * 1024 * 1024)).toBe('1 GiB')
+ expect(formatGfsUploadLimit(1)).toBe('1 byte')
+ })
+
it('uses the writer threshold and rejects invalid capability values', () => {
expect(normalizeInstabilityFailureThreshold(undefined)).toBe(3)
expect(normalizeInstabilityFailureThreshold(1)).toBe(1)
@@ -141,7 +150,7 @@ describe('desktop GFS indexed uploader', () => {
parentRid: 'parent-runtime-lower',
transport,
}).start()
- ).rejects.toThrow(`GFS files are limited to ${100 * 1024 * 1024} bytes by the writer`)
+ ).rejects.toThrow('GFS writer permits files up to 100 MiB for this upload')
expect(createCalls).toBe(0)
} finally {
await rm(root, { recursive: true, force: true })
@@ -248,7 +257,7 @@ describe('desktop GFS indexed uploader', () => {
}).start()
).rejects.toThrow('session admission reached')
expect(compatibilityWarning).toHaveBeenCalledWith(
- 'GFS Upload v2 writer omitted maxFileBytes; using the 209715200-byte compatibility limit'
+ 'GFS Upload v2 writer omitted maxFileBytes; using the 200 MiB compatibility limit'
)
expect(createCalls).toBe(1)
expect((await stat(filePath)).size).toBeLessThanOrEqual(compatibilityMaxFileBytes)
@@ -257,7 +266,7 @@ describe('desktop GFS indexed uploader', () => {
}
})
- it.each([0, -1, 1.5, 1024 * 1024 * 1024 + 1, Number.MAX_SAFE_INTEGER + 1, '314572800', null])(
+ it.each([0, -1, 1.5, '314572800', null])(
'rejects malformed writer maxFileBytes %s as a capability failure',
async maxFileBytes => {
const root = await mkdtemp(join(tmpdir(), 'evenfire-gfs-upload-invalid-limit-'))
@@ -294,6 +303,15 @@ describe('desktop GFS indexed uploader', () => {
}
)
+ it('reports a writer/client compatibility problem above the protocol maximum', () => {
+ expect(() => normalizeUploadProductMaxBytes(1024 * 1024 * 1024 + 1)).toThrow(
+ DesktopUploadCapabilityError
+ )
+ expect(() => normalizeUploadProductMaxBytes(1024 * 1024 * 1024 + 1)).toThrow(
+ /beyond this Desktop's fixed 1 GiB Upload v2 protocol ceiling/
+ )
+ })
+
it('rejects above the 1 GiB protocol maximum before requesting capabilities', async () => {
const root = await mkdtemp(join(tmpdir(), 'evenfire-gfs-upload-protocol-max-'))
try {
diff --git a/desktop-app/src/gfs/upload.ts b/desktop-app/src/gfs/upload.ts
index bd42d2b4e..1b154a41b 100644
--- a/desktop-app/src/gfs/upload.ts
+++ b/desktop-app/src/gfs/upload.ts
@@ -27,11 +27,16 @@ export const GFS_UPLOAD_SERVICE_RETRY_MAX_ATTEMPTS = 6
export const GFS_UPLOAD_RETRY_AFTER_CAP_MS = 5_000
const GFS_UPLOAD_RETRY_BASE_DELAY_MS = 250
const MEBIBYTE_BYTES = 1024 * 1024
+const GIBIBYTE_BYTES = 1024 * MEBIBYTE_BYTES
-function formatBinaryUploadLimit(byteLength: number): string {
- return byteLength % MEBIBYTE_BYTES === 0
- ? `${byteLength / MEBIBYTE_BYTES} MiB`
- : `${byteLength} bytes`
+/**
+ * Presentation only: GFSC remains the authority for the Upload v2 product policy.
+ */
+export function formatGfsUploadLimit(byteLength: number): string {
+ if (byteLength === 1) return '1 byte'
+ if (byteLength % GIBIBYTE_BYTES === 0) return `${byteLength / GIBIBYTE_BYTES} GiB`
+ if (byteLength % MEBIBYTE_BYTES === 0) return `${byteLength / MEBIBYTE_BYTES} MiB`
+ return `${byteLength} bytes`
}
export interface DesktopUploadSession {
@@ -172,15 +177,16 @@ export function allowsLegacyCapabilityFallback(error: unknown): boolean {
export function normalizeUploadProductMaxBytes(value: unknown): number {
if (value === undefined) return GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES
- if (
- !Number.isSafeInteger(value) ||
- (value as number) < 1 ||
- (value as number) > GFS_UPLOAD_V2_PROTOCOL_MAX_BYTES
- ) {
+ if (!Number.isSafeInteger(value) || (value as number) < 1) {
throw new DesktopUploadCapabilityError(
'GFS resumable capabilities advertised an invalid file ceiling'
)
}
+ if ((value as number) > GFS_UPLOAD_V2_PROTOCOL_MAX_BYTES) {
+ throw new DesktopUploadCapabilityError(
+ "GFS writer advertises a product limit beyond this Desktop's fixed 1 GiB Upload v2 protocol ceiling; update Desktop or use a compatible writer."
+ )
+ }
return value as number
}
@@ -1413,7 +1419,7 @@ export class DesktopGfsUploadJob {
const productMaxFileBytes = normalizeUploadProductMaxBytes(resumable.maxFileBytes)
if (resumable.maxFileBytes === undefined) {
console.warn(
- `GFS Upload v2 writer omitted maxFileBytes; using the ${GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES}-byte compatibility limit`
+ `GFS Upload v2 writer omitted maxFileBytes; using the ${formatGfsUploadLimit(GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES)} compatibility limit`
)
}
this.input.advertisedConcurrency = resumable.maxConcurrentPartsPerSession
@@ -1439,10 +1445,12 @@ export class DesktopGfsUploadJob {
if (file.size > productMaxFileBytes) {
if (resumable.maxFileBytes === undefined) {
throw new Error(
- `GFS files are limited to the ${formatBinaryUploadLimit(GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES)} compatibility limit because the writer omitted maxFileBytes`
+ `GFS files are limited to the ${formatGfsUploadLimit(GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES)} compatibility limit because the writer omitted maxFileBytes`
)
}
- throw new Error(`GFS files are limited to ${productMaxFileBytes} bytes by the writer`)
+ throw new Error(
+ `GFS writer permits files up to ${formatGfsUploadLimit(productMaxFileBytes)} for this upload`
+ )
}
const target = this.input.operation === 'create' ? this.input.parentRid : this.input.resourceRid
if (!target) throw new Error(`${this.input.operation} upload target is required`)
diff --git a/desktop-app/test/e2e-playwright/gfs-upload-v2.test.ts b/desktop-app/test/e2e-playwright/gfs-upload-v2.test.ts
index 77960d7e6..d99b764d0 100644
--- a/desktop-app/test/e2e-playwright/gfs-upload-v2.test.ts
+++ b/desktop-app/test/e2e-playwright/gfs-upload-v2.test.ts
@@ -12,6 +12,7 @@ import {
uniqueGfsFixtureName,
} from '../../../tests/e2e/gfsUiFixtures'
import {
+ E2E_GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES,
GFS_UPLOAD_V2_BOUNDARIES,
createDiskUploadFixture,
createOversizedDiskUploadFixture,
@@ -480,7 +481,9 @@ test.describe('GFS Upload v2 — packaged Desktop runtime product policy', () =>
rejectedSource.filePath
)
await expect(
- appPage.getByRole('alert').filter({ hasText: `GFS writer limit is ${lowerMax} bytes` })
+ appPage
+ .getByRole('alert')
+ .filter({ hasText: `GFS writer permits files up to ${lowerMax / (1024 * 1024)} MiB` })
).toBeVisible({ timeout: 30_000 })
expect(
countGfsCreateSessions(fixture.resourceId, rejectedSource.fileName, getE2EUserId())
@@ -513,7 +516,9 @@ test.describe('GFS Upload v2 — approved negative Desktop journeys', () => {
)
test.setTimeout(45 * 60_000)
- test('rejects a 209715201-byte file through the visible Desktop action', async ({ appPage }) => {
+ test('rejects a file one byte above the compatibility default through the visible Desktop action', async ({
+ appPage,
+ }) => {
const fixtureName = uniqueGfsFixtureName('e2e-gfs-v2-negative-oversize-desktop')
let cleanupFixture: ReturnType<typeof seedGfsDirectoryFixture> | undefined
let cleanupSource: Awaited<ReturnType<typeof createOversizedDiskUploadFixture>> | undefined
@@ -537,7 +542,9 @@ test.describe('GFS Upload v2 — approved negative Desktop journeys', () => {
source.filePath
)
await expect(
- appPage.getByRole('alert').filter({ hasText: 'GFS writer limit is 209715200 bytes' })
+ appPage.getByRole('alert').filter({
+ hasText: `GFS writer permits files up to ${E2E_GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES / (1024 * 1024)} MiB`,
+ })
).toBeVisible({ timeout: 15_000 })
await expect
.poll(