You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 18, 2026. It is now read-only.
Severity: HIGH Category: Dispensables > Duplicated Code Files:cli/src/cmd/exec/commands/mcp.go, cli/src/internal/executor/executor.go
Description
The Key Vault environment resolution logic is duplicated between two independent implementations:
prepareEnvironmentForMCP() in mcp.go (lines 325-354) — used by MCP handlers
prepareEnvironment() + hasKeyVaultReferences() in executor.go (lines 186-250) — used by CLI executor
Both functions perform the same steps:
Call os.Environ() to get environment variables
Check if any variables contain Key Vault references using keyvault.IsKeyVaultReference()
Create a keyvault.NewKeyVaultResolver()
Call ResolveEnvironmentVariables() with best-effort or fail-fast semantics
Fall back to the original environment on error
The MCP version is a simplified copy that always uses best-effort mode, while the CLI version supports configurable StopOnKeyVaultError. A comment in the MCP version explicitly states it "mirrors the CLI execution path."
Refactoring Recommendation
Extract the shared logic into a reusable function in the executor package or a new internal/envresolver package:
Code Smell: Duplicated Code (Dispensables)
Severity: HIGH
Category: Dispensables > Duplicated Code
Files:
cli/src/cmd/exec/commands/mcp.go,cli/src/internal/executor/executor.goDescription
The Key Vault environment resolution logic is duplicated between two independent implementations:
prepareEnvironmentForMCP()inmcp.go(lines 325-354) — used by MCP handlersprepareEnvironment()+hasKeyVaultReferences()inexecutor.go(lines 186-250) — used by CLI executorBoth functions perform the same steps:
os.Environ()to get environment variableskeyvault.IsKeyVaultReference()keyvault.NewKeyVaultResolver()ResolveEnvironmentVariables()with best-effort or fail-fast semanticsThe MCP version is a simplified copy that always uses best-effort mode, while the CLI version supports configurable
StopOnKeyVaultError. A comment in the MCP version explicitly states it "mirrors the CLI execution path."Refactoring Recommendation
Extract the shared logic into a reusable function in the
executorpackage or a newinternal/envresolverpackage:The CLI and MCP paths would both call this function with their respective options.
Impact