Skip to content

Commit b7bc482

Browse files
committed
fix issues pointed by the ai reviewer
1 parent 0fa72ae commit b7bc482

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/makim/core.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def _call_shell_app(
257257
def _call_shell_remote(
258258
self, cmd: str, host_config: dict[str, Any], exit_on_error: bool = True
259259
) -> bool:
260+
ssh: paramiko.SSHClient | None = None
260261
try:
261262
# Render the host configuration values
262263
env, _ = self._load_scoped_data('task')
@@ -288,7 +289,6 @@ def _call_shell_remote(
288289
)
289290
return False
290291

291-
ssh.close()
292292
return True
293293
except paramiko.AuthenticationException:
294294
MakimLogs.raise_error(
@@ -311,6 +311,12 @@ def _call_shell_remote(
311311
exit_on_error=exit_on_error,
312312
)
313313
return False
314+
finally:
315+
if ssh is not None:
316+
try:
317+
ssh.close()
318+
except Exception:
319+
pass # nosec B110 - Ignore errors when closing SSH connection
314320

315321
def _render_host_config(
316322
self, host_config: dict[str, Any], env: dict[str, str]
@@ -925,8 +931,11 @@ def _prepare_hook_args(
925931
)
926932
)
927933

934+
# Update with original args, excluding 'task' to preserve hook task
935+
args_hook.update(
936+
{k: v for k, v in args_hook_original.items() if k != 'task'}
937+
)
928938
args_hook['task'] = hook_data['task']
929-
args_hook.update(args_hook_original)
930939
return args_hook
931940

932941
def _execute_hook(

0 commit comments

Comments
 (0)