What the agent does
The agent reads how the retry policy is built before it renames anything. In a library like last9/pyhystrix, which wraps requests with retries and a circuit breaker, pyhystrix.py creates a Retry subclass on line 128 and passes method_whitelist=bargs[METHOD_WHITELIST] on line 133. The set it passes comes from Config.method_whitelist() in config.py, which returns HEAD and GET, and get_backoff_args adds the caller's own method when the caller asks for max_tries. setup.py pins urllib3 == 1.25.6 and requests == 2.22.0 exactly, which is why the library works when installed alone and breaks as soon as an application that needs a newer requests installs beside it.
It then reproduces the failure on three versions, because each tells the reader something different. On the pinned 1.25.6 the suite, 23 unittest cases in tests.py, passes. On urllib3 1.26 the same code still passes and prints the warning that preceded the removal: Using 'method_whitelist' with Retry is deprecated and will be removed in v2.0. Use 'allowed_methods' instead. On urllib3 2.8.0, 13 of the 23 cases error with the TypeError from the title, raised from line 128 on every request the wrapper makes.
The fix in the library is the keyword: allowed_methods= in place of method_whitelist=. The agent keeps Config.method_whitelist() under its existing name, since applications may override it, and says so. After that one-word change it runs the suite on urllib3 2 again and does not stop at the first green-looking result: 21 cases pass and 2 still error, now with 'HTTPResponse' object has no attribute 'get_redirect_location'. Those two come from the test file's own mock. CustomHTTPResponseMock replaces HTTPConnectionPool._make_request with a function that returns a raw http.client.HTTPResponse, which urllib3 1.x wrapped afterwards and urllib3 2 expects to be its own response class already.
So the agent separates the two. The library change is complete and needs urllib3 1.26 or newer, the first release that accepts allowed_methods. The two remaining errors are a test fixture reaching into a private urllib3 method, and the agent rewrites that mock to return a urllib3 response, or replaces it with a local HTTP server that answers the status the test wants. It loosens the exact pins in setup.py to ranges it ran, and notes that one timeout test needs outbound network access.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This project fails with: TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist'. Fix it so it works on urllib3 2. Read the dependency files and say how urllib3 and requests are constrained, and whether exact pins in a library's install_requires are what keeps the error hidden. Find every place a urllib3 Retry (or a subclass) is built, every use of method_whitelist, DEFAULT_METHOD_WHITELIST, and any config key or public function named after it. Run the test suite three times in clean environments: on the pinned versions, on the newest urllib3 1.26 with warnings shown, and on the newest urllib3 2 with the newest requests; report pass and fail counts and quote the first traceback of each distinct error. Change the keyword to allowed_methods. Keep public names that callers may override, or add the new name and keep the old one as an alias, and say which you did. Run the suite on urllib3 2 again. For any test that still fails, decide whether the library or the test is wrong: a test that patches a private urllib3 method or returns an http.client response is a test problem; fix the test without weakening what it asserts. Check that retries still happen for the same methods and status codes as before by reading the test that counts attempts. Set the urllib3 requirement to the lowest version that accepts allowed_methods and widen requests to match. Open a pull request with the three test summaries.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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 in three parts. The first is one line in pyhystrix.py. The second is the mock in tests.py. The third is setup.py, where the exact pins on urllib3 and requests become lower bounds, with urllib3 >= 1.26 because older releases reject the new keyword. The description carries the three test summaries side by side, so a reviewer sees the pinned baseline, the deprecation warning on 1.26 and the 13 errors on 2.x before reading any diff.
It then shows the suite after the keyword change alone, with the two mock errors and their traceback, and after the mock is repaired. Keeping that middle step visible matters. A pull request that changed the library and the tests together and reported only the final green run would hide that the tests needed surgery to pass, and a reviewer should know which assertions were touched.
A reviewer checks two things. One is retry behaviour: the set passed as allowed_methods is the same frozenset as before, so HEAD and GET are retried by default and other methods only when the caller sets max_tries. The other is the new floor. An application still on urllib3 1.25 cannot take this release, and the description says that in one sentence so it can go in the changelog.
Run it on every error-tracker issue with this TypeError
In a service this error appears on the first outbound request after a deploy that moved urllib3, and every request through the retrying session fails with it, so an error tracker groups it into one loud issue. Most trackers sign their own webhook deliveries and cannot send the Authorization: Bearer header a Rush webhook trigger requires. Put a small handler on your server between them: it receives the tracker's webhook, keeps issues whose title contains unexpected keyword argument 'method_whitelist', and forwards the payload to the trigger's URL with the trigger's secret. The stack trace is placed after the saved prompt as event text.
The frame at the top of that trace says whether the caller is your code or a dependency. When it is a dependency, the agent reports the package and the first release of it that uses allowed_methods, and the pull request is a version bump instead of a code change. Set the automation's max runs per hour low, since one bad deploy can open the same issue in several services.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
The rename takes seconds. Proving it across the version boundary takes three environments and three test runs, and the interesting result is in the last one, where the suite is still red for a reason unrelated to the title. On a laptop that is the point where people either pin urllib3 below 2 and move on, or delete the failing tests. The run does the comparison in its own sandbox, with a clean install per version, and the transcript keeps each summary and traceback.
It is also a change where the answer depends on who owns the failing frame. The same error message comes from application code, from an internal library with exact pins, and from third-party packages that were slow to update. Reading the traceback and the dependency tree before editing is what stops the agent from patching a file under site-packages or renaming a public config hook that other teams override.
Frequently asked questions
What replaced method_whitelist?
allowed_methods, with the same meaning: the set of HTTP methods a Retry is allowed to retry. urllib3 added it in 1.26, kept the old name with a deprecation warning through the 1.26 series, and removed the old name in 2.0. Retry.DEFAULT_METHOD_WHITELIST became Retry.DEFAULT_ALLOWED_METHODS in the same way.
Can I support urllib3 1.25 and 2 at the same time?
Not with one keyword, since 1.25 knows only the old name and 2 only the new one. Code that must span both checks which attribute Retry has and picks the keyword. The agent adds that branch only when the prompt says 1.25 has to stay supported; otherwise it raises the floor to 1.26.
Why not pin urllib3<2?
It works until another dependency requires urllib3 2, and current requests releases accept it, so the resolver will choose it whenever nothing holds it back. A pin in a library also pushes the conflict onto every application that installs it. The agent fixes the call and widens the range.
The error is raised inside a package I do not maintain. What happens then?
The agent does not edit installed packages. It names the package and version in the traceback, checks whether a newer release uses allowed_methods, and proposes that upgrade with the test results. When no fixed release exists it reports that and the narrowest pin that keeps the service running.
More urllib3 jobs
More jobs like this: Fix a bug from an alert
- Fix "[DEP0060] DeprecationWarning: The util._extend API is deprecated" From http-proxy on Node 22 (http-proxy)
- Fix a Failed Vercel Deployment of an Astro Site (Astro)
- Fix a Failed Vercel Deployment of a Next.js App (Next.js)
- Fix a Failed Vercel Deployment of a Nuxt App (Nuxt)
- Fix a Failed Vercel Deployment of a React App (React)