Skip to content

fix(kaos): log ssh failures when enabled#848

Open
powerfooI wants to merge 2 commits intomainfrom
fix/kaos-ssh-logging
Open

fix(kaos): log ssh failures when enabled#848
powerfooI wants to merge 2 commits intomainfrom
fix/kaos-ssh-logging

Conversation

@powerfooI
Copy link
Collaborator

@powerfooI powerfooI commented Feb 2, 2026

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 4 additional flags in Devin Review.

Open in Devin Review

Comment on lines +404 to +407
existed = await self._sftp.exists(str(path))
if existed and not exist_ok:
raise FileExistsError(f"{path} already exists")
await self._sftp.mkdir(str(path))
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 mkdir with exist_ok=True and parents=False fails when directory exists

When calling mkdir(path, parents=False, exist_ok=True) on an existing directory, the method will fail instead of succeeding silently.

Click to expand

Root Cause

The logic at lines 404-407 checks if the directory exists and raises FileExistsError only when exist_ok=False. However, when exist_ok=True and the directory exists, the code still proceeds to call await self._sftp.mkdir(str(path)) which will fail because the directory already exists.

existed = await self._sftp.exists(str(path))
if existed and not exist_ok:
    raise FileExistsError(f"{path} already exists")
await self._sftp.mkdir(str(path))  # Called even when existed=True and exist_ok=True!

Expected Behavior

When exist_ok=True and the directory already exists, the method should return successfully without attempting to create the directory.

Actual Behavior

The method attempts to create the directory even when it exists, causing an SFTP error.

Fix

The code should skip the mkdir call when the directory already exists:

if existed:
    if not exist_ok:
        raise FileExistsError(f"{path} already exists")
else:
    await self._sftp.mkdir(str(path))

Note: This is a pre-existing bug that was present before this PR.

Recommendation: Change the logic to skip mkdir when directory exists: if existed: if not exist_ok: raise FileExistsError(...) else: await self._sftp.mkdir(str(path))

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant