You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A recent commit has accidentally removed cryptography==44.0.2 from requirements.txt. Because the core /account/login process imports and relies on cryptography.fernet.Fernet to encrypt S3 keys into session cookies, any clean build or new installation of the Open Library environment completely fails to log in, raising a ModuleNotFoundError and throwing a 500 Internal Server Error.
During login attempts, the traceback screen shows:
<class 'ModuleNotFoundError'> at /account/login
No module named 'cryptography'
Traceback:
Python /openlibrary/openlibrary/accounts/model.py in _get_fernet, line 90
def _get_fernet():
from cryptography.fernet import Fernet
Root Cause Analysis
Commit e420e4506 ("feat(security): store S3 keys as encrypted session cookie") introduced cookie-based encryption for S3 keys. This feature imported cryptography.fernet.Fernet and pinned cryptography==44.0.2 in requirements.txt.
Commit 3ee6fa309 ("feat(proxy): route outbound requests through single authenticated http_proxy (feat(proxy): route outbound requests through single authenticated http_proxy #12724)") updated outbound requests proxy settings. During this commit, cryptography==44.0.2 was accidentally omitted/deleted from requirements.txt (likely due to an outdated local environment or merge conflict misresolution), while the application code (openlibrary/accounts/model.py) still expects it.
Proposed Fix
Add cryptography==44.0.2 back to requirements.txt under beautifulsoup4:
Restart the web services to force Python to reload packages from disk:
docker compose restart web fast_web
Go to http://localhost:8080/account/login and try to log in.
Expected behavior: Login succeeds and redirects you.
Actual behavior: Server responds with a 500 Internal Server Error due to ModuleNotFoundError: No module named 'cryptography'.
Method 2:
In any fresh setup (like CI/CD pipelines, staging/production builds, or clean checkouts):
Build the base image from scratch (ensuring local virtual environments like .venv are deleted or ignored so they don't break the build context on Windows):
Build the development containers on top of your new base image:
docker compose build --no-cache && docker compose up -d
Go to http://localhost:8080/account/login and attempt to log in.
Expected behavior: Login succeeds and redirects you.
Actual behavior: Login crashes with ModuleNotFoundError: No module named 'cryptography'.
Context
Browser (Chrome, Safari, Firefox, etc):
OS (Windows, Mac, etc):
Logged in (Y/N):
Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
Requirements Checklist
[ ]
Related files
Stakeholders
Instructions for Contributors
Please run these commands to ensure your repository is up to date beforecreating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
Problem
A recent commit has accidentally removed
cryptography==44.0.2fromrequirements.txt. Because the core/account/loginprocess imports and relies oncryptography.fernet.Fernetto encrypt S3 keys into session cookies, any clean build or new installation of the Open Library environment completely fails to log in, raising aModuleNotFoundErrorand throwing a500 Internal Server Error.During login attempts, the traceback screen shows:
Root Cause Analysis
cryptography.fernet.Fernetand pinnedcryptography==44.0.2inrequirements.txt.cryptography==44.0.2was accidentally omitted/deleted fromrequirements.txt(likely due to an outdated local environment or merge conflict misresolution), while the application code (openlibrary/accounts/model.py) still expects it.Proposed Fix
Add
cryptography==44.0.2back torequirements.txtunderbeautifulsoup4:Reproducing the bug
Method 1
http://localhost:8080/account/loginand try to log in.500 Internal Server Errordue toModuleNotFoundError: No module named 'cryptography'.Method 2:
In any fresh setup (like CI/CD pipelines, staging/production builds, or clean checkouts):
.venvare deleted or ignored so they don't break the build context on Windows):docker build -f docker/Dockerfile.olbase -t openlibrary/olbase:latest .docker compose build --no-cache && docker compose up -dhttp://localhost:8080/account/loginand attempt to log in.ModuleNotFoundError: No module named 'cryptography'.Context
Breakdown
Implementation Details (for maintainers)
Requirements Checklist
Related files
Stakeholders
Instructions for Contributors