Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/yellow-rocks-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@workflow/world-vercel": patch
"@workflow/core": patch
---

Omit private backend URLs from request diagnostics and sanitize captured E2E CLI output before it reaches CI reports.
17 changes: 13 additions & 4 deletions packages/core/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function getCliArgs(): string {
return '';
}

return `--backend vercel --verbose`;
return `--backend vercel`;
}

const awaitCommand = async (
Expand All @@ -222,12 +222,17 @@ const awaitCommand = async (
cwd,
env: {
...process.env,
DEBUG: '1',
WORKFLOW_NO_UPDATE_CHECK: '1',
...envOverrides,
DEBUG: '',
},
});

const privateBackendUrl = process.env.VERCEL_WORKFLOW_SERVER_URL;
const sanitizeOutput = (text: string) =>
privateBackendUrl
? text.replaceAll(privateBackendUrl, '[REDACTED]')
: text;
let stdout = '';
let stderr = '';

Expand All @@ -236,7 +241,6 @@ const awaitCommand = async (
const text = Buffer.isBuffer(chunk)
? chunk.toString('utf8')
: String(chunk);
process.stdout.write(chunk);
stdout += text;
});
}
Expand All @@ -246,13 +250,18 @@ const awaitCommand = async (
const text = Buffer.isBuffer(chunk)
? chunk.toString('utf8')
: String(chunk);
process.stderr.write(chunk);
stderr += text;
});
}

child.on('error', (err) => reject(err));
child.on('close', (code, signal) => {
// Sanitize complete streams before logging or returning them: the URL
// can straddle chunks, and reporters persist errors outside CI masking.
stdout = sanitizeOutput(stdout);
stderr = sanitizeOutput(stderr);
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
if (code !== 0) {
const exitReason = signal
? `killed by signal ${signal}`
Expand Down
35 changes: 35 additions & 0 deletions packages/world-vercel/src/http-core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getTransientTransportCode,
getVercelDiagnostics,
instrumentedFetch,
logCurlRepro,
parseRetryAfter,
resolveVercelApiToken,
STREAM_APPEND_DEADLINE_RESERVE_MS,
Expand Down Expand Up @@ -515,3 +516,37 @@ describe('resolveVercelApiToken', () => {
expect(await resolveVercelApiToken()).toBeNull();
});
});

describe('logCurlRepro', () => {
afterEach(() => {
vi.unstubAllEnvs();
vi.restoreAllMocks();
});

it('omits authorization and the private backend URL but keeps safe headers', () => {
vi.stubEnv('DEBUG', '1');
const log = vi.spyOn(console, 'error').mockImplementation(() => {});
logCurlRepro(
'GET',
'https://api.vercel.com/workflow/events',
new Headers({
Authorization: 'Bearer test-token',
'X-Vercel-Workflow-Api-Url': 'https://private-backend.invalid',
'content-type': 'application/json',
})
);
const output = JSON.stringify(log.mock.calls);
expect(output).toContain('curl -X GET');
expect(output).toContain('content-type: application/json');
expect(output).not.toContain('test-token');
expect(output).not.toContain('private-backend.invalid');
expect(output).not.toContain('x-vercel-workflow-api-url');
});

it('does not log without DEBUG', () => {
vi.stubEnv('DEBUG', '');
const log = vi.spyOn(console, 'error').mockImplementation(() => {});
logCurlRepro('GET', 'https://example.invalid', new Headers());
expect(log).not.toHaveBeenCalled();
});
});
11 changes: 7 additions & 4 deletions packages/world-vercel/src/http-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ export function httpLog(

/**
* On a failed request with `DEBUG` set, print a copy-pasteable `curl` that
* reproduces it (authorization header stripped). Separate from
* HTTP_DEBUG_ENABLED so any DEBUG value opts in, matching the original v3
* behavior.
* reproduces it (authorization and private backend headers stripped). Separate
* from HTTP_DEBUG_ENABLED so any DEBUG value opts in, matching the original
* v3 behavior.
*/
export function logCurlRepro(
method: string,
Expand All @@ -282,7 +282,10 @@ export function logCurlRepro(
): void {
if (!process.env.DEBUG) return;
const stringifiedHeaders = Array.from(headers.entries())
.filter(([key]) => key.toLowerCase() !== 'authorization')
.filter(([key]) => {
const name = key.toLowerCase();
return name !== 'authorization' && name !== 'x-vercel-workflow-api-url';
})
.map(([key, value]) => `-H "${key}: ${value}"`)
.join(' ');
console.error(
Expand Down