Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/blocks/aws/src/lib/actions/cli/aws-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export async function runCommand(
): Promise<string> {
const envVars: any = {
AWS_DEFAULT_REGION: region,
HOME: process.env['HOME'] ?? '/tmp',
PATH: process.env['PATH'] ?? '',
};

Expand Down
5 changes: 2 additions & 3 deletions packages/blocks/aws/test/cli/aws-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('awsCli', () => {
'some command',
'aws',
{
HOME: process.env['HOME'],
AWS_ACCESS_KEY_ID: credential.accessKeyId,
AWS_SECRET_ACCESS_KEY: credential.secretAccessKey,
AWS_SESSION_TOKEN: credential.sessionToken,
Expand All @@ -62,10 +63,8 @@ describe('awsCli', () => {
'some command',
'aws',
{
HOME: process.env['HOME'],
AWS_DEFAULT_REGION: 'region',
AWS_ACCESS_KEY_ID: undefined,
AWS_SECRET_ACCESS_KEY: undefined,
AWS_SESSION_TOKEN: undefined,
PATH: process.env['PATH'],
},
);
Expand Down
1 change: 1 addition & 0 deletions packages/blocks/azure/src/lib/azure-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function runCommand(
subscription?: string,
): Promise<string> {
const envVars: Record<string, string> = {
HOME: process.env['HOME'] || '/tmp',
PATH: process.env['PATH'] || '',
};

Expand Down
75 changes: 39 additions & 36 deletions packages/blocks/azure/test/azure-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ describe('azureCli', () => {
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
`login --service-principal --username ${credentials.clientId} --password ${credentials.clientSecret} --tenant ${credentials.tenantId}`,
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
Comment on lines +32 to 35
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions expect HOME to equal process.env['HOME'], but the implementation now falls back to '/tmp' when HOME is unset. This makes the test environment-dependent and can fail in CI/containers where HOME is not defined. Update the expectation to match the fallback logic (or explicitly set process.env.HOME to a known value in the test setup and restore it).

Copilot uses AI. Check for mistakes.
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
'some command',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
});

Expand All @@ -64,31 +64,31 @@ describe('azureCli', () => {
1,
`login --service-principal --username ${credentials.clientId} --password ${credentials.clientSecret} --tenant ${credentials.tenantId}`,
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
expect(commonMock.runCliCommand).toHaveBeenNthCalledWith(
2,
'account set --subscription subscriptionId',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
expect(commonMock.runCliCommand).toHaveBeenNthCalledWith(
3,
'some command',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
});

Expand All @@ -109,19 +109,19 @@ describe('azureCli', () => {
1,
'account set --subscription subscriptionId',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
expect(commonMock.runCliCommand).toHaveBeenNthCalledWith(
2,
'some command',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
});

Expand All @@ -138,10 +138,10 @@ describe('azureCli', () => {
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
'some command',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
process.env = originalEnv;
});
Expand All @@ -164,11 +164,12 @@ describe('azureCli', () => {
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
'some command',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: process.env['AZURE_CONFIG_DIR'],
AZURE_EXTENSION_DIR: '/mock/config/dir/extensions',
},
}),
);
process.env = originalEnv;
});
Expand All @@ -192,20 +193,22 @@ describe('azureCli', () => {
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
`login --service-principal --username ${credentials.clientId} --password ${credentials.clientSecret} --tenant ${credentials.tenantId}`,
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: '/mock/config/dir/extensions',
},
}),
);
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
'some command',
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: '/mock/config/dir/extensions',
},
}),
);
process.env = originalEnv;
});
Expand All @@ -221,11 +224,11 @@ describe('azureCli', () => {
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
`login --service-principal --username ${credentials.clientId} --password ${credentials.clientSecret} --tenant ${credentials.tenantId}`,
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
});

Expand All @@ -244,11 +247,11 @@ describe('azureCli', () => {
expect(commonMock.runCliCommand).toHaveBeenCalledWith(
`login --service-principal --username ${credentials.clientId} --password ${credentials.clientSecret} --tenant ${credentials.tenantId}`,
'az',
{
expect.objectContaining({
HOME: process.env['HOME'],
PATH: process.env['PATH'],
AZURE_CONFIG_DIR: expect.any(String),
AZURE_EXTENSION_DIR: expect.any(String),
},
}),
);
});
});
1 change: 1 addition & 0 deletions packages/blocks/google-cloud/src/lib/google-cloud-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function runCommands(
executeCliTool = 'gcloud',
): Promise<string[]> {
const envVars: Record<string, string> = {
HOME: process.env['HOME'] || '/tmp',
PATH: process.env['PATH'] || '',
CLOUDSDK_CORE_DISABLE_PROMPTS: '1',
};
Expand Down
1 change: 1 addition & 0 deletions packages/openops/src/lib/google-cloud/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async function runAuthCommand(keyObject: string): Promise<string> {
const gcpConfigDir = await getDefaultCloudSDKConfig();

const envVars: Record<string, string> = {
HOME: process.env['HOME'] || '/tmp',
PATH: process.env['PATH'] || '',
CLOUDSDK_CORE_DISABLE_PROMPTS: '1',
CLOUDSDK_CONFIG: gcpConfigDir,
Expand Down
2 changes: 2 additions & 0 deletions packages/server/api/src/app/ai/mcp/cost-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ async function initializeMcpClient(
command: pythonPath,
args: [serverPath],
env: {
HOME: process.env['HOME'] ?? '/tmp',
PATH: process.env['PATH'] ?? '',
AWS_ACCESS_KEY_ID: credentials.accessKeyId,
AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
AWS_REGION: credentials.region,
Expand Down
2 changes: 2 additions & 0 deletions packages/server/api/src/app/ai/mcp/openops-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export async function getOpenOpsTools(
command: pythonPath,
args: [serverPath],
env: {
HOME: process.env['HOME'] ?? '/tmp',
PATH: process.env['PATH'] ?? '',
OPENAPI_SCHEMA_PATH: tempSchemaPath,
AUTH_TOKEN: serviceToken,
API_BASE_URL: networkUtls.getInternalApiUrl(),
Expand Down
Loading