ATH-MaaS/Pixelle-Video · error · HTTPException

str(e)

Error message

str(e)

What it means

The GET file handler's outer catch-all: HTTPExceptions are re-raised unchanged, but any other exception during path resolution or file streaming becomes HTTP 500 with str(e) as detail. Typical sources are OS-level errors (PermissionError on the file, OSError) raised while reading the file.

Source

Thrown at api/routers/files.py:127

            '.html': 'text/html',
            '.json': 'application/json',
        }
        media_type = media_types.get(suffix, 'application/octet-stream')
        
        # Use inline disposition for browser preview
        return FileResponse(
            path=str(abs_path),
            media_type=media_type,
            headers={
                "Content-Disposition": f'inline; filename="{abs_path.name}"'
            }
        )
        
    except HTTPException:
        raise
    except Exception as e:
        logger.error(f"File access error: {e}")
        raise HTTPException(status_code=500, detail=str(e))

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Check the server log 'File access error: ...' to see the underlying OS error.
  2. Fix file permissions (chmod/chown) so the server process can read the file.
  3. Ensure the container/server user matches the user that wrote the outputs, or use a shared group.
  4. Verify the file is readable and not a broken symlink at the resolved path.
  5. Return a sanitized generic 500 detail and log the traceback instead of str(e).

Example fix

// before
except Exception as e:
    logger.error(f"File access error: {e}")
    raise HTTPException(status_code=500, detail=str(e))
// after
except Exception:
    logger.exception("File access error")
    raise HTTPException(status_code=500, detail="File access failed")
Defensive patterns

Strategy: try-catch

Validate before calling

import fs from 'fs';
const abs = path.resolve('output', filePath);
try { fs.accessSync(abs, fs.constants.R_OK); } catch { throw new Error(`Server process cannot read ${filePath}: check permissions`); }

Try / catch

try {
  const res = await fetch(`/api/files/${encodeURIComponent(filePath)}`);
  if (res.status === 500) throw new Error('File access failed on server — check file permissions and server logs');
  if (!res.ok) throw new Error(`File fetch failed: ${res.status}`);
  return await res.blob();
} catch (err) {
  logger.error('File fetch failed', err);
  throw err;
}

Prevention

When it happens

Trigger: GET to the files endpoint where reading the file raises a non-HTTP error — PermissionError (file owned by another user, mode 000), OSError from IO problems, or a bug between the security checks and FileResponse construction.

Common situations: Files created by a container user unreadable by the server process; NFS/permission issues after volume mounting; files with restrictive umask; server running as a different user than the pipeline that wrote outputs.

Related errors


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/84e70aa0ccf4eda3. Report an issue: GitHub.