calesthio/OpenMontage · error · HTTPException

unknown project: {project_id}

Error message

unknown project: {project_id}

What it means

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.

Source

Thrown at backlot/server.py:317

    @app.middleware("http")
    async def ui_no_cache(request, call_next):
        response = await call_next(request)
        path = request.url.path
        if path == "/" or path.startswith("/ui") or path.startswith("/p/"):
            response.headers["Cache-Control"] = "no-cache"
        return response

    return app


def _safe_project_dir(project_id: str) -> Path:
    # ':' rejects Windows drive-relative ids like "C:" (PROJECTS_DIR / "C:"
    # collapses back to PROJECTS_DIR itself).
    if any(c in project_id for c in "/\\:") or project_id in (".", ".."):
        raise HTTPException(status_code=400, detail="invalid project id")
    project_dir = PROJECTS_DIR / project_id
    if not project_dir.is_dir():
        raise HTTPException(status_code=404, detail=f"unknown project: {project_id}")
    return project_dir


def _sse(payload: dict) -> str:
    return f"data: {json.dumps(payload)}\n\n"


def _thumbnail_for(source: Path, width: int) -> Optional[Path]:
    """Downscale an image (or extract a video poster frame) to a cached JPEG."""
    suffix = source.suffix.lower()
    is_image = suffix in {".png", ".jpg", ".jpeg", ".webp", ".gif"}
    is_video = suffix in {".mp4", ".webm", ".mov"}
    if not (is_image or is_video):
        return None
    try:
        import hashlib
        stat = source.stat()
        key = hashlib.sha1(

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Center-crop the image to a ratio within 0.4–2.5 (ideally 1:1, 4:3, 16:9, or 9:16).
  2. Pad the image with neutral background to bring the ratio into range.
  3. Choose a reference frame that includes more context instead of a tight sliver.

Example fix

# before
inputs = {"reference_image_path": "strip_6000x1200.jpg"}
# after
from PIL import Image
img = Image.open("strip_6000x1200.jpg")
w = min(img.width, int(img.height * 2.5))
img = img.crop(((img.width - w)//2, 0, (img.width - w)//2 + w, img.height))
img.save("ref_ratio_ok.jpg")
inputs = {"reference_image_path": "ref_ratio_ok.jpg"}
Defensive patterns

Strategy: validation

Validate before calling

from PIL import Image
with Image.open(ref_path) as im:
    w, h = im.size
    ratio = w / h
assert 0.4 <= ratio <= 2.5, ratio

Type guard

def ratio_ok(w: int, h: int) -> bool:
    return 0.4 <= w / h <= 2.5

Try / catch

try:
    tool.run(inputs)
except ValueError as e:
    if "width/height ratio" in str(e):
        center_crop_to_ratio(ref_path)  # crop to <= 2.5:1 / >= 1:2.5, retry
        tool.run(inputs)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Cropping a subject out of a poster leaving a tall thin slice; full-width website hero crops; scrolling-phone-screenshot stitching.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/e56333b59a46c8ac. Report an issue: GitHub.