Skip to content

bug: backend down on Render after vision.py additions — imagehash/Pillow import crash on startup #9

Description

@ankitrmishra01

Bug report

Live app: https://green-lens-tau.vercel.app/
Backend: https://greenlens-backend-n3ws.onrender.com
Reported after: commits by cypher redye adding vision.py + imagehash features

Errors observed (browser console)

  • greenlens-backend-n3ws.onrender.com/api/auth/register → 401
  • greenlens-backend-n3ws.onrender.com/api/auth/register → 422
  • greenlens-backend-n3ws.onrender.com/api/organizations → 400

What's actually happening

All endpoints return "Host not in allowlist" / 403 from Render's proxy.
This is NOT a CORS issue and NOT an auth issue. It means the FastAPI app
never starts — Render's router has nothing to forward requests to, so it
serves this error itself.

Verified by hitting the root endpoint directly:
curl https://greenlens-backend-n3ws.onrender.com/
→ "Host not in allowlist" (Render proxy error, not FastAPI)


Root cause

Cypher Redye's recent commits added vision.py and the following new imports to main.py:

import imagehash
from vision import scan_receipt_or_food, get_image_hash

vision.py also imports:
from PIL import Image
import imagehash

These two packages (Pillow, ImageHash) were added to requirements.txt but
Render only installs dependencies on a fresh build/deploy. If the deploy
did not complete successfully, the running container is missing these packages
and the app crashes at import time before it can bind to a port.

Expected crash log on Render:
ModuleNotFoundError: No module named 'imagehash'
or
ModuleNotFoundError: No module named 'PIL'

This causes a startup crash → Render returns 403 for all requests → every
API call from the frontend fails, including register and login.


Steps to verify

  1. Go to Render Dashboard → greenlens-backend service → Logs
  2. Look for ModuleNotFoundError near the top of the most recent deploy log
  3. Confirm the app never reaches "Application startup complete"

Fix

Step 1 — Trigger a manual redeploy on Render

Render Dashboard → greenlens-backend → Manual Deploy → Deploy latest commit

This forces a fresh pip install -r requirements.txt which will install
Pillow and ImageHash correctly.

Step 2 — Confirm requirements.txt has both packages

Already present in the file:
Pillow>=10.0.0
ImageHash>=4.3.1

No code changes needed — a clean redeploy should be enough.

Step 3 — Verify after deploy

curl https://greenlens-backend-n3ws.onrender.com/

Expected response after fix:
{
"message": "GreenLens API v2.0.0 — Track Your Carbon. Change Your Campus.",
"status": "healthy",
"cors_patched": true
}


Why previous diagnosis was wrong

Earlier analysis pointed to VITE_API_URL being blank and the Axios
interceptor attaching stale tokens. While those are real minor issues,
they are NOT the cause of registration being broken. The backend is
completely unreachable — no request ever reaches FastAPI code at all.


Labels

bug, backend, render, deployment, vision

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions