fix: capture SCP stderr for better error messages
This commit is contained in:
parent
6e161a6105
commit
cd5f31505a
1 changed files with 9 additions and 2 deletions
|
|
@ -475,7 +475,8 @@ def scp_start(
|
||||||
|
|
||||||
logger.info("Starting SCP pull: %s → %s", remote, dest)
|
logger.info("Starting SCP pull: %s → %s", remote, dest)
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(cmd, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
proc = subprocess.Popen(cmd, env=env, stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.PIPE, text=True)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return JSONResponse({"phase": "error", "error": f"Failed to start SCP: {exc}"}, status_code=500)
|
return JSONResponse({"phase": "error", "error": f"Failed to start SCP: {exc}"}, status_code=500)
|
||||||
|
|
||||||
|
|
@ -516,11 +517,17 @@ def scp_progress(session_id: str, filename: str):
|
||||||
if poll is not None:
|
if poll is not None:
|
||||||
_active_scp.pop(key, None)
|
_active_scp.pop(key, None)
|
||||||
if poll != 0:
|
if poll != 0:
|
||||||
|
stderr_output = ""
|
||||||
|
try:
|
||||||
|
stderr_output = proc.stderr.read()[:500] if proc.stderr else ""
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
if dest.exists():
|
if dest.exists():
|
||||||
dest.unlink(missing_ok=True)
|
dest.unlink(missing_ok=True)
|
||||||
|
logger.error("SCP pull failed (rc=%d): %s", poll, stderr_output)
|
||||||
return JSONResponse({
|
return JSONResponse({
|
||||||
"phase": "error",
|
"phase": "error",
|
||||||
"error": f"SCP pull failed (exit code {poll}). Check credentials and remote path.",
|
"error": f"SCP pull failed (exit code {poll}). {stderr_output}",
|
||||||
"file_size_bytes": current_bytes,
|
"file_size_bytes": current_bytes,
|
||||||
})
|
})
|
||||||
final_bytes = dest.stat().st_size
|
final_bytes = dest.stat().st_size
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue