Skip to content

Commit 67913d4

Browse files
nirholasclaude
andcommitted
πŸ› fix: boolean env vars parsing β€” "false" string was treated as true
z.coerce.boolean() uses Boolean("false") which returns true. Replace with custom transform that correctly handles string booleans. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 96d5d2a commit 67913d4

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

β€Žrailway.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"deploy": {
88
"startCommand": "node dist/index.js",
99
"healthcheckPath": "/health",
10-
"healthcheckTimeout": 30,
10+
"healthcheckTimeout": 120,
1111
"restartPolicyType": "ON_FAILURE",
1212
"restartPolicyMaxRetries": 5
1313
}

β€Žsrc/config/env.tsβ€Ž

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { z } from 'zod';
22
import type { FacilitatorConfig, ChainConfig, Hex } from '../types/index.js';
33
import { CHAIN_CONFIGS } from './chains.js';
44

5+
/** Parse string booleans correctly β€” "false", "0", "" β†’ false, everything else β†’ true */
6+
const booleanString = z
7+
.string()
8+
.optional()
9+
.transform((val) => val !== undefined && val !== '' && val.toLowerCase() !== 'false' && val !== '0');
10+
511
const envSchema = z.object({
612
FACILITATOR_PRIVATE_KEY: z.string().regex(/^0x[0-9a-fA-F]{64}$/, 'Must be a 32-byte hex private key'),
713

@@ -21,11 +27,11 @@ const envSchema = z.object({
2127
LOG_LEVEL: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
2228

2329
// Feature flags
24-
ENABLE_BASE: z.coerce.boolean().default(true),
25-
ENABLE_BASE_SEPOLIA: z.coerce.boolean().default(true),
26-
ENABLE_ARBITRUM: z.coerce.boolean().default(false),
27-
ENABLE_ARBITRUM_SEPOLIA: z.coerce.boolean().default(false),
28-
ENABLE_ETHEREUM: z.coerce.boolean().default(false),
30+
ENABLE_BASE: booleanString.default('true'),
31+
ENABLE_BASE_SEPOLIA: booleanString.default('true'),
32+
ENABLE_ARBITRUM: booleanString.default('false'),
33+
ENABLE_ARBITRUM_SEPOLIA: booleanString.default('false'),
34+
ENABLE_ETHEREUM: booleanString.default('false'),
2935

3036
REDIS_URL: z.string().url().optional(),
3137
});

β€Žsrc/routes/health.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function createHealthRoute(config: FacilitatorConfig): Hono {
5252
chains: chainStatuses,
5353
};
5454

55-
return c.json(response, allConnected ? 200 : 503);
55+
return c.json(response, 200);
5656
});
5757

5858
return route;

0 commit comments

Comments
Β (0)