Skip to content

Fix passlib/bcrypt incompatibility by switching to argon2#4

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/update-passlib-version
Open

Fix passlib/bcrypt incompatibility by switching to argon2#4
Copilot wants to merge 3 commits into
mainfrom
copilot/update-passlib-version

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

passlib==1.7.4 is incompatible with bcrypt>=4.0.0, causing ValueError: password cannot be longer than 72 bytes on Python 3.12/Windows. Since passlib is effectively unmaintained at 1.7.4, switching to argon2 is the cleaner fix.

Changes

  • requirements.txt: passlib[bcrypt]==1.7.4passlib[argon2]==1.7.4 (pulls in argon2-cffi)
  • app/services/auth.py: CryptContext(schemes=["bcrypt"])CryptContext(schemes=["argon2"])
  • .gitignore: Added root-level ignore for __pycache__/, *.db, .env, and other artifacts that were previously untracked
# before
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

# after
pwd_context = CryptContext(schemes=["argon2"], deprecated="auto")

Note: Existing bcrypt hashes in the database will no longer verify after this change. For this environment the DB is seeded fresh on each run, so there is no migration concern — but this should be considered before applying to any deployment with persistent user data.

Original prompt

Fix passlib/bcrypt compatibility issue on Windows with Python 3.12

The application fails with ValueError: password cannot be longer than 72 bytes when using passlib==1.7.4 with bcrypt==5.0.0 on Windows Python 3.12.

Root cause: Old passlib version (1.7.4) is incompatible with newer bcrypt (5.0.0). The passlib version in requirements.txt is outdated.

Solution: Update requirements.txt to use a newer passlib version that's compatible with bcrypt 5.0.0, or use argon2 instead of bcrypt for password hashing.

Recommended fix:

  1. Update passlib to latest version in requirements.txt, OR
  2. Change password hashing algorithm from bcrypt to argon2 which has better compatibility

This will resolve the Windows/Python 3.12 compatibility issue.

The following is the prior conversation context from the user's chat exploration (may be truncated):

Assistant: uvicorn is not installed. You need to install the dependencies from requirements.txt first.

Run this:

cd ~/customer-support-env
pip install -r requirements.txt

This will install uvicorn and all other required packages. After that, you can run:

uvicorn app.main:app --host 0.0.0.0 --port 7860

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix passlib/bcrypt compatibility issue on Windows with Python 3.12 Fix passlib/bcrypt incompatibility by switching to argon2 Apr 12, 2026
Copilot AI requested a review from apy65360-hash April 12, 2026 15:51
@apy65360-hash apy65360-hash marked this pull request as ready for review May 12, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants