:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(replay): keep rasterizer STS credential refresh off the proxy (#72824)
Daniel Escribano77946f6130ef
diff --git a/nodejs/src/session-replay/recording-rasterizer/__tests__/storage.test.ts b/nodejs/src/session-replay/recording-rasterizer/__tests__/storage.test.tsindex 700acf0311f3..049a90d1644f 100644--- a/nodejs/src/session-replay/recording-rasterizer/__tests__/storage.test.ts+++ b/nodejs/src/session-replay/recording-rasterizer/__tests__/storage.test.ts@@ -150,7 +150,6 @@ describe('S3 client proxy routing', () => {expect(config).not.toHaveProperty('requestHandler')expect(config).not.toHaveProperty('credentials')expect(HttpsProxyAgentMock).not.toHaveBeenCalled()- expect(mockDefaultProvider).not.toHaveBeenCalled()})it.each([@@ -158,36 +157,23 @@ describe('S3 client proxy routing', () => {{ source: 'HTTP_PROXY fallback', env: 'HTTP_PROXY' as const },{ source: 'lowercase https_proxy', env: 'https_proxy' as const },{ source: 'lowercase http_proxy', env: 'http_proxy' as const },- ])('routes both S3 and STS credential refresh through the proxy when $source is set', async ({ env }) => {+ ])('routes S3 through the proxy but leaves credential refresh direct when $source is set', async ({ env }) => {process.env[env] = 'http://smokescreen.smokescreen.svc.cluster.local:4750'const s3Client = await triggerS3Client()const [config] = s3Client.mock.calls[0]expect(HttpsProxyAgentMock).toHaveBeenCalledWith('http://smokescreen.smokescreen.svc.cluster.local:4750')- // S3 client requests+ // S3 requests go through smokescreenexpect(config.requestHandler).toEqual({httpsAgent: { __proxyAgent: 'http://smokescreen.smokescreen.svc.cluster.local:4750' },})- // Internal STS / IRSA credential refresh- expect(mockDefaultProvider).toHaveBeenCalledWith({- clientConfig: {- requestHandler: {- httpsAgent: { __proxyAgent: 'http://smokescreen.smokescreen.svc.cluster.local:4750' },- },- },- })- expect(config.credentials).toEqual({- __credentialsProvider: {- clientConfig: {- requestHandler: {- httpsAgent: { __proxyAgent: 'http://smokescreen.smokescreen.svc.cluster.local:4750' },- },- },- },- })+ // IRSA credential refresh must NOT be routed through the proxy: we don't+ // override credentials, so the SDK default provider dials STS direct.+ expect(config).not.toHaveProperty('credentials')+ expect(mockDefaultProvider).not.toHaveBeenCalled()})it.each(['false', 'False', 'FALSE', '0', 'no', 'off', ' false '])(- 'RASTERIZER_USE_PROXY=%j keeps both S3 and STS direct even when HTTPS_PROXY is set',+ 'RASTERIZER_USE_PROXY=%j keeps S3 direct even when HTTPS_PROXY is set',async (value) => {process.env.HTTPS_PROXY = 'http://smokescreen:4750'process.env.RASTERIZER_USE_PROXY = value@@ -196,21 +182,19 @@ describe('S3 client proxy routing', () => {expect(config).not.toHaveProperty('requestHandler')expect(config).not.toHaveProperty('credentials')expect(HttpsProxyAgentMock).not.toHaveBeenCalled()- expect(mockDefaultProvider).not.toHaveBeenCalled()})it.each(['true', '1', 'enabled', 'yes', 'disabled'])(- 'RASTERIZER_USE_PROXY=%j leaves both S3 and STS routed via proxy (only known falsy values disable)',+ 'RASTERIZER_USE_PROXY=%j routes S3 via the proxy (only known falsy values disable)',async (value) => {process.env.HTTPS_PROXY = 'http://smokescreen:4750'process.env.RASTERIZER_USE_PROXY = valueconst s3Client = await triggerS3Client()const [config] = s3Client.mock.calls[0]expect(config.requestHandler).toBeDefined()- expect(config.credentials).toBeDefined()+ expect(config).not.toHaveProperty('credentials')expect(HttpsProxyAgentMock).toHaveBeenCalledWith('http://smokescreen:4750')- expect(mockDefaultProvider).toHaveBeenCalledTimes(1)})})diff --git a/nodejs/src/session-replay/recording-rasterizer/storage.ts b/nodejs/src/session-replay/recording-rasterizer/storage.tsindex f63456d6740c..c5c81e5bd847 100644--- a/nodejs/src/session-replay/recording-rasterizer/storage.ts+++ b/nodejs/src/session-replay/recording-rasterizer/storage.ts@@ -1,5 +1,4 @@import { S3Client } from '@aws-sdk/client-s3'-import { defaultProvider } from '@aws-sdk/credential-provider-node'import { Upload } from '@aws-sdk/lib-storage'import * as fs from 'fs'import { HttpsProxyAgent } from 'https-proxy-agent'@@ -36,11 +35,10 @@ function getS3Client(): S3Client {region: config.s3Region,...(config.s3Endpoint ? { endpoint: config.s3Endpoint, forcePathStyle: true } : {}),...(requestHandler ? { requestHandler } : {}),- // Route the IRSA credential-refresh STS call through the proxy too.- // The SDK's default credential provider spawns an internal STSClient- // that does NOT inherit our requestHandler — pass clientConfig so it- // does. Without this, S3 goes via smokescreen but STS dials direct.- ...(requestHandler ? { credentials: defaultProvider({ clientConfig: { requestHandler } }) } : {}),+ // S3 goes through the proxy, but credential refresh must dial direct+ // (the SDK does not honor NO_PROXY). The default credential provider+ // does this on its own, so long as we don't hand it our proxied+ // requestHandler.})}return s3Client