harry0703/MoneyPrinterTurbo · error · HttpException
{request_id}: background music validation is unavailable
Error message
{request_id}: background music validation is unavailable What it means
Raised by the BGM upload endpoint when the service raises BgmServiceError: an infrastructure failure in the toolchain or storage, not a user mistake. Per the code comments, this must not masquerade as a user file error, so the endpoint returns 500 with a fixed message ('background music validation is unavailable') and keeps the internal reason (FFmpeg missing/failed, storage dir unwritable, timeout) only in error logs. The stable message also avoids leaking server paths.
Source
Thrown at app/controllers/v1/video.py:364
safe_filename = bgm_service.save_bgm_upload(file.filename, file.file)
except bgm_service.BgmUploadError as exc:
# 上传失败通常可以由用户更换文件后恢复,因此记录 request_id 和明确原因,
# 但不输出文件内容或绝对路径,避免日志泄露用户数据。
logger.warning(
f"background music upload rejected: request_id={request_id}, error={str(exc)}"
)
raise HttpException(
task_id=request_id,
status_code=400,
message=f"{request_id}: {str(exc)}",
)
except bgm_service.BgmServiceError as exc:
# 工具链或存储故障属于服务端问题,不能伪装成用户文件错误。日志保留
# request_id 和内部原因,HTTP 响应只返回稳定文案,避免暴露服务器路径。
logger.error(
f"background music upload failed: request_id={request_id}, error={str(exc)}"
)
raise HttpException(
task_id=request_id,
status_code=500,
message=f"{request_id}: background music validation is unavailable",
)
response = {"file": safe_filename}
return utils.get_response(200, response)
@router.get(
"/video_materials", response_model=VideoMaterialRetrieveResponse, summary="Retrieve local video materials"
)
def get_video_materials_list(request: Request):
allowed_suffixes = ("mp4", "mov", "avi", "flv", "mkv", "jpg", "jpeg", "png")
local_videos_dir = utils.storage_dir("local_videos", create=True)
files = []
for suffix in allowed_suffixes:
files.extend(glob.glob(os.path.join(local_videos_dir, f"*.{suffix}")))
# 文件系统枚举顺序不稳定,直接返回会导致“顺序拼接”在不同机器或不同View on GitHub (pinned to 1f9f19c202)
Solutions
- Check server logs (logger.error line includes request_id and the real str(exc)) to identify the infrastructure cause.
- Ensure FFmpeg is available to the server process — install the system ffmpeg package or verify imageio-ffmpeg is in the environment.
- Verify the BGM upload directory exists and is writable by the service user.
- Retry once after fixing the environment; if the cause was a validation timeout under load, retry when the machine is calmer.
Example fix
# before: slim Dockerfile with no ffmpeg # FROM python:3.11-slim # RUN pip install -r requirements.txt # after FROM python:3.11-slim RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/* RUN pip install -r requirements.txt
Defensive patterns
Strategy: fallback
Validate before calling
# ops pre-flight on the server host
import shutil
assert shutil.which("ffmpeg") or importlib.util.find_spec("imageio_ffmpeg"), "no FFmpeg available"
import os
assert os.access(bgm_upload_dir, os.W_OK), "BGM storage not writable" Try / catch
try:
resp = upload_bgm(name, fh)
except BgmServiceUnavailable: # client mapping of the 500 stable message
notify_ops("background music validation is unavailable") # do NOT tell user to change the file
raise Prevention
- Include ffmpeg (or imageio-ffmpeg) in deployment images and verify in health checks.
- Make the BGM storage directory writable and mounted on a healthy volume.
- Watch server error logs — the real cause is only there, never in the HTTP response.
When it happens
Trigger: FFmpeg binary missing or not executable (e.g. imageio-ffmpeg package not installed); storage directory creation failing due to permissions; FFmpeg crashing with OSError; FFmpeg exceeding the validation timeout because the system is overloaded — each surfaces as this same 500.
Common situations: Deploying to a slim Docker image without the ffmpeg package; read-only volumes mounted at the BGM storage path; broken imageio-ffmpeg install after a dependency upgrade; disk-full or NFS hangs on the storage dir.
Related errors
- uploaded file must contain a decodable audio stream
- {request_id}: {str(exc)}
- invalid background music filename
- unsupported background music format; supported formats: {sup
- background music file is empty or missing
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/a7d666ffffa1c063.
Report an issue: GitHub.