Skip to content

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

TypeScript

fix(gfs): reject noncanonical product limits

Josuéd39f2eaa0f7d
diff --git a/gfs-controller/src/config.test.ts b/gfs-controller/src/config.test.ts
index 9a62cde2b..e2adc119f 100644
--- a/gfs-controller/src/config.test.ts
+++ b/gfs-controller/src/config.test.ts
@@ -129,6 +129,7 @@ describe('GFS_UPLOAD_V2 strict disabled contract', () => {
})
it.each([
+ ['one byte', 1],
['100 MiB', 100 * 1024 * 1024],
['200 MiB', 200 * 1024 * 1024],
['250 MiB', 250 * 1024 * 1024],
@@ -140,7 +141,21 @@ describe('GFS_UPLOAD_V2 strict disabled contract', () => {
expect(loadConfig().uploadV2.productMaxFileBytes).toBe(bytes)
})
- it.each(['', '0', '-1', '1.5', 'NaN', 'Infinity', '1e3', '9007199254740992'])(
+ it.each([
+ '',
+ '0',
+ '-1',
+ '1.5',
+ 'NaN',
+ 'Infinity',
+ '1e3',
+ '01',
+ '+1',
+ ' 1',
+ '1 ',
+ '9007199254740992',
+ '1073741825',
+ ])(
'rejects invalid runtime product limit %s',
raw => {
vi.stubEnv('GFS_DEV_MODE', 'true')
diff --git a/gfs-controller/src/config.ts b/gfs-controller/src/config.ts
index 78d8990e3..3d5e96e5c 100644
--- a/gfs-controller/src/config.ts
+++ b/gfs-controller/src/config.ts
@@ -167,6 +167,13 @@ function uploadInteger(name: string, defaultValue: number, min: number, max: num
return value
}
+function requireCanonicalUploadInteger(name: string): void {
+ const raw = process.env[name]
+ if (raw !== undefined && !/^(?:0|[1-9][0-9]*)$/.test(raw)) {
+ throw new Error(`[gfsc] ${name} must use canonical unsigned decimal integer syntax`)
+ }
+}
+
function uploadDurationMs(name: string, defaultValue: number, max: number): number {
const raw = process.env[name]
if (raw === undefined) return defaultValue
@@ -238,6 +245,8 @@ function uploadConfig(): GfsUploadConfig {
GFS_UPLOAD_V2_DEFAULT_PRODUCT_MAX_BYTES,
GFS_UPLOAD_V2_PROTOCOL_MAX_BYTES
)
+ requireCanonicalUploadInteger('GFS_UPLOAD_PRODUCT_MAX_FILE_BYTES')
+ requireCanonicalUploadInteger('GFS_UPLOAD_MAX_FILE_BYTES')
const productMaxFileBytes = uploadIntegerWithAlias(
'GFS_UPLOAD_PRODUCT_MAX_FILE_BYTES',
'GFS_UPLOAD_MAX_FILE_BYTES',