darkoperator / darkoperator/Posh-SSH
Get-SFTPItem does not throw on error
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
The CmdLet Get-SFTPItem does not throw a terminating error on failure, it only displays a warning. The $error variable isn't even populated, so it seems like nothing happened.
This is a big issue for us, as we can't handle exceptions like big files failing because of disk full, connection interruptions, ...
Or maybe I'm missing something?
try {
$params = @{
SessionId = 1
Path = '\bigFile.mpg'
Destination = 'c:\bigFile.mpg'
}
Get-SFTPItem @params -ErrorAction Stop
}
catch {
"Error: $_" # we should end up here on failure, but we don't
}
function New-BigFileHC {
Param (
[string]$Path = 'c:\bigFile.txt',
[int]$SizeInGB = 10
)
$sizeInBytes = $SizeInGB * 1GB
$fs = [System.IO.File]::Create($Path)
$fs.SetLength($sizeInBytes)
$fs.Close()
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Get-SFTPItem implementation and reproduce the reported failure with -ErrorAction Stop using the example parameters. Trace the failed transfer path and verify that a disk-full or connection error becomes a terminating error and populates $error, then rerun the try/catch example to confirm the catch block is reached.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100