Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(gfs): cover public 413 and geometry boundaries
Alfredo Lopezd19d30046e34
diff --git a/control-ui/lib/__tests__/gfsFileUpload.test.ts b/control-ui/lib/__tests__/gfsFileUpload.test.tsindex 70ea22c0d..8f1ac151e 100644--- a/control-ui/lib/__tests__/gfsFileUpload.test.ts+++ b/control-ui/lib/__tests__/gfsFileUpload.test.ts@@ -47,12 +47,14 @@ describe('normalizeInstabilityFailureThreshold', () => {describe('isRetryableUploadStatus', () => {it('uses the same transient allowlist as Desktop and does not retry storage exhaustion', () => {expect(isRetryableUploadStatus(503)).toBe(true)+ expect(isRetryableUploadStatus(413)).toBe(false)expect(isRetryableUploadStatus(507)).toBe(false)expect(isRetryableUploadStatus(501)).toBe(false)})it('only reconciles statuses whose response may follow a committed write', () => {expect(isAmbiguousUploadStatus(500)).toBe(true)+ expect(isAmbiguousUploadStatus(413)).toBe(false)expect(isAmbiguousUploadStatus(429)).toBe(false)expect(isAmbiguousUploadStatus(507)).toBe(false)expect(isAmbiguousUploadStatus(501)).toBe(false)diff --git a/desktop-app/src/gfs/upload.test.ts b/desktop-app/src/gfs/upload.test.tsindex 71da03882..7c468052e 100644--- a/desktop-app/src/gfs/upload.test.ts+++ b/desktop-app/src/gfs/upload.test.ts@@ -34,9 +34,11 @@ describe('desktop GFS indexed uploader', () => {it('uses the same transient status allowlist as Control UI', () => {expect(isRetryableUploadStatus(503)).toBe(true)+ expect(isRetryableUploadStatus(413)).toBe(false)expect(isRetryableUploadStatus(507)).toBe(false)expect(isRetryableUploadStatus(501)).toBe(false)expect(isAmbiguousUploadStatus(500)).toBe(true)+ expect(isAmbiguousUploadStatus(413)).toBe(false)expect(isAmbiguousUploadStatus(429)).toBe(false)expect(isAmbiguousUploadStatus(507)).toBe(false)})diff --git a/external-rest-api/package-lock.json b/external-rest-api/package-lock.jsonindex d149cfba2..c43c7c19e 100644--- a/external-rest-api/package-lock.json+++ b/external-rest-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-external-rest-api",- "version": "0.1.73",+ "version": "0.1.74","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-external-rest-api",- "version": "0.1.73",+ "version": "0.1.74","dependencies": {"cors": "^2.8.5","express": "^4.21.2",diff --git a/external-rest-api/package.json b/external-rest-api/package.jsonindex 2012fd655..5acf68823 100644--- a/external-rest-api/package.json+++ b/external-rest-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-external-rest-api",- "version": "0.1.73",+ "version": "0.1.74","description": "External REST API for profile, team management, and RPC token brokerage","main": "dist/main.js","engines": {diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.tsindex 4677676c6..2fb0956e3 100644--- a/external-rest-api/src/releaseManifest.ts+++ b/external-rest-api/src/releaseManifest.ts@@ -8,7 +8,7 @@ export type ReleaseManifest = {export const releaseManifest: ReleaseManifest = {releaseId: 'v0.7.0',- externalRestApiVersion: '0.1.73',+ externalRestApiVersion: '0.1.74',rpcProxyVersion: '0.1.64',desktopVersion: '0.7.0',minimumDesktopVersion: '0.1.252',diff --git a/external-rest-api/test/routes.gfs.test.ts b/external-rest-api/test/routes.gfs.test.tsindex 936e8c9e2..6c5e3a14e 100644--- a/external-rest-api/test/routes.gfs.test.ts+++ b/external-rest-api/test/routes.gfs.test.ts@@ -341,6 +341,42 @@ describe('routes/gfs /me/gfs/* (user session passthrough → /external/gfs/*)',expect(res.body).toEqual({ error: 'escalation_rejected' })})+ it('preserves a public 413 payload_too_large response and its safe transport headers', async () => {+ const body = {+ ok: false,+ error: {+ code: 'payload_too_large',+ message: 'upload exceeds the 200 MiB product limit',+ },+ }+ clientMock.controlApiRequest.mockRejectedValue(+ new ControlApiError(+ 'payload too large',+ 413,+ body,+ new Headers({+ 'content-type': 'application/json',+ 'retry-after': '9',+ 'upload-length': '209715200',+ 'x-ratelimit-limit': '16',+ 'x-internal-secret': 'must-not-cross-the-public-boundary',+ })+ )+ )++ const res = await request(buildApp())+ .put('/me/gfs/resources/abc/content?drive=main')+ .set('authorization', 'Bearer sess-xyz')+ .send({ contentBase64: 'AAAA' })++ expect(res.status).toBe(413)+ expect(res.body).toEqual(body)+ expect(res.headers['retry-after']).toBe('9')+ expect(res.headers['upload-length']).toBe('209715200')+ expect(res.headers['x-ratelimit-limit']).toBe('16')+ expect(res.headers['x-internal-secret']).toBeUndefined()+ })+it('propagates GFS transport statuses/body/headers without changing retry semantics', async () => {// 507 is terminal for Desktop/Control UI, while 408/425 and the transient// 5xx family are retryable. The public relay must not turn any of them intodiff --git a/gfs-controller/src/upload/protocol.test.ts b/gfs-controller/src/upload/protocol.test.tsindex f10911d68..97584d9c4 100644--- a/gfs-controller/src/upload/protocol.test.ts+++ b/gfs-controller/src/upload/protocol.test.ts@@ -11,6 +11,7 @@ import {isGfsUploadV2Route,partCountFor,partGeometry,+ validateGeometry,validatePartGeometry,} from './protocol'@@ -62,6 +63,35 @@ describe('GFS Upload v2 frozen contract', () => {)})+ it('pins the preferred and hard part boundaries and rejects invalid geometry deterministically', () => {+ const preferred = {+ expectedBytes: GFS_UPLOAD_V2_PREFERRED_PART_BYTES,+ partBytes: GFS_UPLOAD_V2_PREFERRED_PART_BYTES,+ }+ expect(partCountFor(preferred)).toBe(1)+ expect(partGeometry(preferred, 0).lengthBytes).toBe(GFS_UPLOAD_V2_PREFERRED_PART_BYTES)++ const hardMaximum = {+ expectedBytes: GFS_UPLOAD_V2_MAX_PART_BYTES,+ partBytes: GFS_UPLOAD_V2_MAX_PART_BYTES,+ }+ expect(partCountFor(hardMaximum)).toBe(1)+ expect(partGeometry(hardMaximum, 0).lengthBytes).toBe(GFS_UPLOAD_V2_MAX_PART_BYTES)++ expect(() => validateGeometry({ expectedBytes: 1, partBytes: 0 })).toThrow(+ 'partBytes must be an integer'+ )+ expect(() =>+ validateGeometry({+ expectedBytes: GFS_UPLOAD_V2_MAX_PART_BYTES,+ partBytes: GFS_UPLOAD_V2_MAX_PART_BYTES + 1,+ })+ ).toThrow('partBytes must be an integer')+ expect(() =>+ partGeometry({ expectedBytes: 0, partBytes: GFS_UPLOAD_V2_PREFERRED_PART_BYTES }, 0)+ ).toThrow('invalid part number')+ })+it.each([[0, 1 * 1024 * 1024],[1, 1 * 1024 * 1024],diff --git a/gfs-controller/src/upload/uploadSession.test.ts b/gfs-controller/src/upload/uploadSession.test.tsindex ab83a8ef1..3319633d8 100644--- a/gfs-controller/src/upload/uploadSession.test.ts+++ b/gfs-controller/src/upload/uploadSession.test.ts@@ -11,7 +11,7 @@ import {type Transactor,type TxClient,} from '../db/writeStore'-import { partGeometry } from './protocol'+import { GFS_UPLOAD_V2_PRODUCT_MAX_BYTES, partGeometry } from './protocol'import { GfsUploadSessionService, type UploadSessionServiceDeps } from './uploadSession'type Row = Record<string, unknown>@@ -503,6 +503,48 @@ async function settleWithin<T>(}describe('GfsUploadSessionService', () => {+ it('accepts exactly 200 MiB, rejects one byte over before allocation, and enforces part-count geometry', async () => {+ tempRoot = await mkdtemp(join(tmpdir(), 'gfsc-upload-boundary-'))+ const input = {+ ...principal,+ operation: 'create' as const,+ parentRid: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',+ name: 'boundary.bin',+ }++ const exactDb = new MemoryDb()+ const exact = await service(exactDb, CONFIG).create({+ ...input,+ sizeBytes: GFS_UPLOAD_V2_PRODUCT_MAX_BYTES,+ idempotencyKey: '11111111-1111-4111-8111-111111111112',+ })+ expect(exact.created).toBe(true)+ expect(exact.session.expectedBytes).toBe(GFS_UPLOAD_V2_PRODUCT_MAX_BYTES)+ expect(exact.session.partBytes).toBe(8 * 1024 * 1024)+ expect(exact.session.partCount).toBe(25)+ expect(exactDb.sessions).toHaveLength(1)++ const overDb = new MemoryDb()+ await expect(+ service(overDb, CONFIG).create({+ ...input,+ sizeBytes: GFS_UPLOAD_V2_PRODUCT_MAX_BYTES + 1,+ idempotencyKey: '11111111-1111-4111-8111-111111111113',+ })+ ).rejects.toMatchObject({ code: 'payload_too_large' })+ expect(overDb.sessions).toHaveLength(0)++ const partCountDb = new MemoryDb()+ await expect(+ service(partCountDb, { ...CONFIG, maxPartCount: 24 }).create({+ ...input,+ sizeBytes: GFS_UPLOAD_V2_PRODUCT_MAX_BYTES,+ idempotencyKey: '11111111-1111-4111-8111-111111111114',+ })+ ).rejects.toMatchObject({ code: 'payload_too_large' })+ expect(partCountDb.sessions).toHaveLength(0)+ })+it('creates idempotent sessions and keeps indexed commits separate from contiguous progress',{ timeout: 15_000 },