Skip to content

Commit f6c9878

Browse files
authored
Fix intermittent test failure in Safe Inputs API key generation (#6696)
1 parent a75e010 commit f6c9878

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/daily-performance-summary.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/test-python-safe-input.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/js/generate_safe_inputs_config.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
*/
1111
function generateSafeInputsConfig({ core, crypto }) {
1212
// Generate a secure random API key for the MCP server
13-
// Using 32 bytes gives us 256 bits of entropy
14-
const apiKeyBuffer = crypto.randomBytes(32);
13+
// Using 33 bytes gives us 264 bits of entropy and ensures at least 40 characters
14+
// after base64 encoding and removing special characters
15+
const apiKeyBuffer = crypto.randomBytes(33);
1516
const apiKey = apiKeyBuffer.toString("base64").replace(/[/+=]/g, "");
1617

1718
// Choose a port for the HTTP server (default 3000)

pkg/workflow/js/generate_safe_inputs_config.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe("generateSafeInputsConfig", () => {
5252
it("should generate API keys with sufficient length", () => {
5353
const result = generateSafeInputsConfig({ core: mockCore, crypto });
5454

55-
// 32 bytes of random data, base64 encoded without special chars
55+
// 33 bytes of random data, base64 encoded without special chars
5656
// should give us at least 40 characters
5757
expect(result.apiKey.length).toBeGreaterThanOrEqual(40);
5858
});

0 commit comments

Comments
 (0)