# Fix "AttributeError: module 'bcrypt' has no attribute '__about__'" with passlib

Yes. An agent finds which bcrypt release broke passlib, shows where hashing stops working, and fixes the pin or the hashing code with old hashes still verifying.

[Run this on Rush](https://cloud.getrush.ai/run/fix-module-bcrypt-has-no-attribute-about/passlib/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads every place passwords are hashed and how the project installs, because the fix differs depending on whether passlib can stay. In a FastAPI service like Pedroffda/boilerplate-fastapi, `requirements.txt` pins `passlib==1.7.4` and does not list `bcrypt` at all, and `CryptContext(schemes=["bcrypt"], deprecated="auto")` is created four times: in `cli.py`, `api/core/security.py`, `api/services/conta_service.py` and `api/repositories/politica_repository.py`. `security.py` wraps it in `verify_password` and `get_password_hash`. The `Dockerfile` builds on `python:3.9-slim`.

Then it establishes the versions, since the error comes from a combination. passlib 1.7.4 is the newest release on PyPI, from 2020-10-08. bcrypt 4.0.1 shipped on 2022-10-09, 4.1.0 on 2023-11-27, 4.3.0 on 2025-02-28 and 5.0.0 on 2025-09-25. passlib's `handlers/bcrypt.py` reads `_bcrypt.__about__.__version__` at line 620 to log the backend version; 4.1.0 removed that attribute, so from there on passlib logs `(trapped) error reading bcrypt version` with the `AttributeError` traceback. With 4.3.0 that is all that happens: `hash` and `verify` still work. With 5.0.0 the same warning is followed by a real failure: passlib's wraparound self-test at line 380 hashes a 255-byte secret, and bcrypt 5 raises `ValueError: password cannot be longer than 72 bytes, truncate manually if necessary (e.g. my_password[:72])`, so the first `hash()` call fails.

Two more facts shape the fix. With no `bcrypt` package installed at all, passlib on the sandbox's Debian image falls back to its `os_crypt` backend and hashes anyway, which is why the project's own requirements file never showed the problem on Linux. And the requirements file as a whole does not resolve today: `fastapi==0.115.8` needs `starlette<0.46.0` while `starlette==0.49.1` is pinned, which the agent reports as a separate finding.

The agent offers the short fix and the lasting one, both checked. Pinning `bcrypt==4.0.1` restores a silent, working `hash` and `verify`; `bcrypt<5` keeps hashing with the trapped warning in the logs. The lasting fix replaces the four `CryptContext` objects with one helper around `bcrypt.hashpw` and `bcrypt.checkpw`: a passlib `$2b$12$` hash verifies with `bcrypt.checkpw`, a bcrypt hash verifies with passlib, and the one behavioural change is that bcrypt 5 refuses passwords over 72 bytes where passlib silently truncated them, so the helper must decide between truncating and rejecting.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Our API logs \"AttributeError: module 'bcrypt' has no attribute '__about__'\" from passlib and password hashing fails. List every CryptContext in the repository, say which passlib and bcrypt versions the requirements install, and install bcrypt 4.0.1, 4.3.0 and the newest release in turn to show where the warning starts and where hashing breaks, quoting each error. Then propose the smallest pin that restores hashing and a replacement for passlib using the bcrypt package directly, verify that hashes made by the old code still verify with the new one and the reverse, and open a pull request with the version findings, the chosen fix and any requirement conflicts you hit.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request with two commits: one that pins `bcrypt` in `requirements.txt` to a release passlib 1.7.4 works with, and one that replaces the four `CryptContext` instances with a single `hash_password` and `verify_password` pair on the `bcrypt` package. The description lists the four files and lines, the release dates of bcrypt 4.0.1, 4.1.0, 4.3.0 and 5.0.0, the trapped warning, and the 72-byte `ValueError` from the 5.0.0 run.

A reviewer checks the cross-verification transcript: a hash produced by passlib verifies under `bcrypt.checkpw`, and a hash produced by `bcrypt.hashpw` verifies under passlib, so stored passwords keep working through the switch. They also see the 72-byte decision stated explicitly rather than inherited silently from passlib.

The description names the `fastapi` and `starlette` pin conflict found on install and the `os_crypt` fallback that hid the missing `bcrypt` on Linux, so the reviewer knows why the problem surfaced only on some machines.

## Run it on every Sentry error from the login route

The error reaches production as a 500 on login or signup, so the alert is the trigger. Sentry signs its own requests and cannot send a custom Authorization header, so a handler on your server receives the Sentry webhook and forwards the event to a Rush `webhook` trigger with `Authorization: Bearer` and the trigger's secret; the event payload follows the prompt as data, and the run opens the pull request.

For a set of services that all pin passlib, your server sends this request once per repository, each with its own UUID as `request_id` so a retry returns the run already started, and reads each `run.completed` webhook; a key starts at most `max_concurrent` runs at once and queues the rest.

## Why run it on Rush?

The search term is a warning, but the outage is a `ValueError` three stack frames later, and which one you get depends on the bcrypt release the resolver picked that day. In a Rush sandbox the agent installs each release in turn, keeps every traceback, and cross-checks hashes between the old and new code, so the pull request argues from the project's own password paths rather than from a forum thread.

Password hashing is not a place for a guessed fix. The agent reports the fallback backend that hid the problem on Linux, the requirements conflict it found on the way, and the one behavioural difference in the replacement, so the reviewer makes the 72-byte decision knowingly.

## Frequently asked questions

### Is the __about__ error itself the failure?

No. passlib traps it and logs `(trapped) error reading bcrypt version`, then carries on. With bcrypt 4.1 through 4.3 hashing works and the log is the only symptom. With bcrypt 5.0.0 a second error follows: passlib's self-test hashes a 255-byte secret and bcrypt 5 raises `ValueError` for anything over 72 bytes, so `hash()` fails.

### What is the quickest fix?

Pin `bcrypt==4.0.1`, the last release that still has `__about__`, or `bcrypt<5` if the trapped warning in the logs is acceptable. Both were run against the four `CryptContext` call sites and hash and verify succeed.

### Will existing password hashes keep working if I drop passlib?

Yes. passlib's bcrypt scheme writes standard `$2b$12$` hashes, and `bcrypt.checkpw` verifies them; the reverse holds too. The pull request includes that two-way check.

### Why did this never fail in our Docker image?

The requirements file does not list `bcrypt`, and on a Debian-based image passlib falls back to its `os_crypt` backend, which hashes `$2b$` through the system library. The error appears once someone installs the `bcrypt` package, which resolves to 5.0.0 today.

### Why mention the fastapi and starlette pins?

Because a clean `pip install -r requirements.txt` cannot resolve today: `fastapi==0.115.8` requires `starlette<0.46.0` and the file pins `starlette==0.49.1`. The agent hit it while reproducing and reports it so the fix can be installed at all.

## More passlib jobs

- [Replace passlib in a FastAPI App Without Breaking Stored Hashes](https://getrush.ai/run/replace-passlib/passlib/)

## More jobs like this: Fix a bug from an alert

- [Fix "AttributeError: module 'cv2' has no attribute 'xfeatures2d'" by Moving SIFT to cv2.SIFT_create](https://getrush.ai/run/fix-module-cv2-has-no-attribute-xfeatures2d/opencv-python/)
- [Fix "AttributeError: module 'emoji' has no attribute 'UNICODE_EMOJI'"](https://getrush.ai/run/fix-module-emoji-has-no-attribute-unicode-emoji/emoji/)
- [Fix Moment's "Value Provided Is Not in a Recognized RFC2822 or ISO Format" Warning](https://getrush.ai/run/fix-moment-value-provided-is-not-in-a-recognized-format-warning/moment/)
- [Fix "Model.find() no longer accepts a callback" After a Mongoose Upgrade](https://getrush.ai/run/fix-mongoose-callback-error/mongoose/)
- [Fix "DeprecationWarning: Mongoose: the `strictQuery` option will be switched back to `false` by default in Mongoose 7"](https://getrush.ai/run/fix-mongoose-strictquery-deprecation-warning/mongoose/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
