Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Use rediss protocol when tls is enabled (#1068)

Chirag Jaind3d80a250713
diff --git a/.changeset/redis-standalone-tls-url-scheme.md b/.changeset/redis-standalone-tls-url-scheme.md
new file mode 100644
index 000000000..7b17562db
--- /dev/null
+++ b/.changeset/redis-standalone-tls-url-scheme.md
@@ -0,0 +1,5 @@
+---
+"@truefoundry/trueforge": patch
+---
+
+Use the `rediss://` URL scheme for standalone Redis when `REDIS_TLS_ENABLED` is true so TLS connections advertise the secure protocol in the connection URL.
diff --git a/packages/trueforge/src/config.ts b/packages/trueforge/src/config.ts
index daacd98fc..2913f3551 100644
--- a/packages/trueforge/src/config.ts
+++ b/packages/trueforge/src/config.ts
@@ -410,10 +410,12 @@ export function buildRedisStandaloneUrl(parts: {
database: number;
username: string | undefined;
password: string | undefined;
+ tls: boolean;
}): string {
const bareHost = parts.host.startsWith('[') && parts.host.endsWith(']') ? parts.host.slice(1, -1) : parts.host;
const host = isIPv6(bareHost) ? `[${bareHost}]` : bareHost;
- const url = new URL(`redis://${host}:${String(parts.port)}/${String(parts.database)}`);
+ const protocol = parts.tls ? 'rediss' : 'redis';
+ const url = new URL(`${protocol}://${host}:${String(parts.port)}/${String(parts.database)}`);
if (parts.username !== undefined) {
url.username = parts.username;
}
@@ -445,6 +447,11 @@ function resolveRedisConnection(): RedisConnection | undefined {
const username = optionalNonEmptyEnv('REDIS_USERNAME');
const password = getEnv('REDIS_PASSWORD');
const passwordOrUndefined = password === undefined || password === '' ? undefined : password;
+ const tls = parseBoolean({
+ envKey: 'REDIS_TLS_ENABLED',
+ raw: getEnv('REDIS_TLS_ENABLED'),
+ defaultValue: false,
+ });
if (sentinelEnabled) {
const nodes = optionalNonEmptyEnv('REDIS_SENTINEL_NODES');
@@ -497,6 +504,7 @@ function resolveRedisConnection(): RedisConnection | undefined {
database,
username,
password: passwordOrUndefined,
+ tls,
}),
};
}
diff --git a/packages/trueforge/tests/unit/config/config.test.ts b/packages/trueforge/tests/unit/config/config.test.ts
index 54b067058..b2c886989 100644
--- a/packages/trueforge/tests/unit/config/config.test.ts
+++ b/packages/trueforge/tests/unit/config/config.test.ts
@@ -184,6 +184,7 @@ describe('buildRedisStandaloneUrl', () => {
database: 0,
username: undefined,
password: undefined,
+ tls: false,
};
it('builds a hostname URL', () => {