Skip to content

Commit 6d19952

Browse files
committed
refactor(satellite): enhance command path logging for cache misses
1 parent 2a0d589 commit 6d19952

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

services/satellite/src/config/security-validation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,14 @@ export function resolveCommandPath(command: string, logger?: Logger): string {
219219
}
220220

221221
// Fallback for backwards compatibility (should not happen after initialization)
222-
console.warn(`WARNING: Command ${command} not found in cache, using /usr/bin fallback`);
222+
if (logger) {
223+
logger.warn({
224+
operation: 'command_cache_miss',
225+
command,
226+
normalizedCommand,
227+
fallbackPath: `/usr/bin/${normalizedCommand}`
228+
}, `Command ${command} not found in cache, using /usr/bin fallback`);
229+
}
223230
return `/usr/bin/${normalizedCommand}`;
224231
}
225232

services/satellite/src/process/nsjail-spawner.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ALLOWED_BUILD_COMMANDS = new Set(['npm', 'uv', 'pip', 'pip3']);
2020
* Get command path from global cache
2121
* Falls back to /usr/bin if cache miss (should not happen after initialization)
2222
*/
23-
function getCommandPath(command: string): string {
23+
function getCommandPath(command: string, logger?: Logger): string {
2424
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2525
const cache = (global as any).DEPLOYSTACK_COMMAND_CACHE as Map<string, string> | undefined;
2626

@@ -29,7 +29,13 @@ function getCommandPath(command: string): string {
2929
}
3030

3131
// Fallback to /usr/bin (should not happen after proper initialization)
32-
console.warn(`WARNING: Command ${command} not found in cache, using /usr/bin fallback`);
32+
if (logger) {
33+
logger.warn({
34+
operation: 'command_cache_miss',
35+
command,
36+
fallbackPath: `/usr/bin/${command}`
37+
}, `Command ${command} not found in cache, using /usr/bin fallback`);
38+
}
3339
return `/usr/bin/${command}`;
3440
}
3541

@@ -134,7 +140,7 @@ export class ProcessSpawner {
134140

135141
// Get path from runtime-resolved cache (dynamically found at startup)
136142
const normalizedCommand = command.trim().toLowerCase();
137-
const path = getCommandPath(normalizedCommand);
143+
const path = getCommandPath(normalizedCommand, this.logger);
138144

139145
if (!path) {
140146
// This shouldn't happen if command cache was initialized
@@ -457,7 +463,7 @@ export class ProcessSpawner {
457463
}
458464

459465
// Get command path from runtime-resolved cache
460-
const commandPath = getCommandPath(normalizedCommand);
466+
const commandPath = getCommandPath(normalizedCommand, this.logger);
461467
if (!commandPath) {
462468
throw new Error(`Command path not found for build command '${command}'`);
463469
}

0 commit comments

Comments
 (0)