HKUDS/Vibe-Trading · error · HTTPException
Missing filename
Error message
Missing filename
What it means
The upload endpoint requires a multipart file part with a filename. FastAPI reports file.filename as empty when the client sends a file part without a filename attribute, so the request is rejected with 400.
Source
Thrown at agent/src/api/uploads_routes.py:128
raise HTTPException(status_code=404, detail=f"Shadow report not found: {shadow_id}.{format}")
media_type = "text/html; charset=utf-8" if format == "html" else "application/pdf"
return FileResponse(
path,
media_type=media_type,
headers={"Content-Disposition": f'inline; filename="{shadow_id}.{format}"'},
)
@app.post("/upload", dependencies=[Depends(require_auth)])
async def upload_file(file: UploadFile):
"""Upload any document or data file (max 50MB).
Accepts most common formats: PDF, Word, Excel, PowerPoint, images,
CSV/TSV, plain text, JSON, and TOML. Executables, executable-adjacent
source/config/template files, and archives are rejected.
"""
if not file.filename:
raise HTTPException(status_code=400, detail="Missing filename")
filename = Path(file.filename).name
ext = Path(filename).suffix.lower()
if ext in _BLOCKED_UPLOAD_EXT or filename.lower() in _BLOCKED_UPLOAD_NAMES:
raise HTTPException(
status_code=400,
detail="This file type is not allowed for upload.",
)
uploads_dir = _host_uploads_dir()
max_size = _host_max_upload_size()
chunk_size = _host_chunk_size()
safe_name = f"{uuid.uuid4().hex}{ext}"
dest = uploads_dir / safe_name
total_size = 0
try:
uploads_dir.mkdir(parents=True, exist_ok=True)View on GitHub (pinned to 80ffdda44c)
Solutions
- Send multipart/form-data with a named file: curl -F 'file=@report.pdf'
- In JS: formData.append('file', blob, 'report.pdf') — include the third filename argument
- Verify the field name matches what the endpoint expects
Example fix
// before
formData.append('file', blob) // no filename in some clients
// after
formData.append('file', blob, 'report.pdf') Defensive patterns
Strategy: type-guard
Validate before calling
if not file_name: raise ValueError('multipart part needs a filename') Type guard
def has_filename(fd) -> bool:
return bool(getattr(fd, 'filename', None)) Prevention
- Always pass the filename argument in FormData.append
- Use -F 'file=@name.ext' with curl
When it happens
Trigger: POST /uploads with a multipart part named correctly but lacking filename=, or sending raw body/JSON instead of multipart/form-data.
Common situations: Hand-crafted curl requests, fetch/axios calls where the FormData was built incorrectly, or a proxy stripping the filename from the Content-Disposition header.
Related errors
- exit_threshold must be below enter_threshold
- invalid shadow_id
- format must be html or pdf
- This file type is not allowed for upload.
- invalid alpha_id
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/2de661d08883d885.
Report an issue: GitHub.