{"record":{"id":"e56333b59a46c8ac","repo":"calesthio/OpenMontage","slug":"unknown-project-project-id","errorCode":null,"errorMessage":"unknown project: {project_id}","messagePattern":"unknown project: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"backlot/server.py","lineNumber":317,"sourceCode":"    @app.middleware(\"http\")\n    async def ui_no_cache(request, call_next):\n        response = await call_next(request)\n        path = request.url.path\n        if path == \"/\" or path.startswith(\"/ui\") or path.startswith(\"/p/\"):\n            response.headers[\"Cache-Control\"] = \"no-cache\"\n        return response\n\n    return app\n\n\ndef _safe_project_dir(project_id: str) -> Path:\n    # ':' rejects Windows drive-relative ids like \"C:\" (PROJECTS_DIR / \"C:\"\n    # collapses back to PROJECTS_DIR itself).\n    if any(c in project_id for c in \"/\\\\:\") or project_id in (\".\", \"..\"):\n        raise HTTPException(status_code=400, detail=\"invalid project id\")\n    project_dir = PROJECTS_DIR / project_id\n    if not project_dir.is_dir():\n        raise HTTPException(status_code=404, detail=f\"unknown project: {project_id}\")\n    return project_dir\n\n\ndef _sse(payload: dict) -> str:\n    return f\"data: {json.dumps(payload)}\\n\\n\"\n\n\ndef _thumbnail_for(source: Path, width: int) -> Optional[Path]:\n    \"\"\"Downscale an image (or extract a video poster frame) to a cached JPEG.\"\"\"\n    suffix = source.suffix.lower()\n    is_image = suffix in {\".png\", \".jpg\", \".jpeg\", \".webp\", \".gif\"}\n    is_video = suffix in {\".mp4\", \".webm\", \".mov\"}\n    if not (is_image or is_video):\n        return None\n    try:\n        import hashlib\n        stat = source.stat()\n        key = hashlib.sha1(","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/backlot/server.py#L299-L335","documentation":"The reference image's width/height ratio is outside 0.4–2.5, i.e. narrower than 2:5 or wider than 5:2. Ark constrains reference-image aspect ratio; extreme portrait strips or ultra-wide banners fail even when pixel dimensions are in range.","triggerScenarios":"A 6000x1500 ultra-wide panorama (ratio 4.0); a 500x1250 vertical strip (ratio 0.4 boundary at exactly 0.4 passes, below fails); 9:16 screenshot is 0.5625 and passes, but 1:3 phone-cropped slivers do not.","commonSituations":"Cropping a subject out of a poster leaving a tall thin slice; full-width website hero crops; scrolling-phone-screenshot stitching.","solutions":["Center-crop the image to a ratio within 0.4–2.5 (ideally 1:1, 4:3, 16:9, or 9:16).","Pad the image with neutral background to bring the ratio into range.","Choose a reference frame that includes more context instead of a tight sliver."],"exampleFix":"# before\ninputs = {\"reference_image_path\": \"strip_6000x1200.jpg\"}\n# after\nfrom PIL import Image\nimg = Image.open(\"strip_6000x1200.jpg\")\nw = min(img.width, int(img.height * 2.5))\nimg = img.crop(((img.width - w)//2, 0, (img.width - w)//2 + w, img.height))\nimg.save(\"ref_ratio_ok.jpg\")\ninputs = {\"reference_image_path\": \"ref_ratio_ok.jpg\"}","handlingStrategy":"validation","validationCode":"from PIL import Image\nwith Image.open(ref_path) as im:\n    w, h = im.size\n    ratio = w / h\nassert 0.4 <= ratio <= 2.5, ratio","typeGuard":"def ratio_ok(w: int, h: int) -> bool:\n    return 0.4 <= w / h <= 2.5","tryCatchPattern":"try:\n    tool.run(inputs)\nexcept ValueError as e:\n    if \"width/height ratio\" in str(e):\n        center_crop_to_ratio(ref_path)  # crop to <= 2.5:1 / >= 1:2.5, retry\n        tool.run(inputs)\n    else:\n        raise","preventionTips":["Prefer conventional framing (1:1, 16:9, 9:16) for reference images.","Validate ratio whenever you crop subjects out of larger compositions."],"tags":["python","validation","aspect-ratio","image","reference","seedance"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}