Repository navigation
fix: allow safe Basic auth after async connection-abort probes - #721
Merged
Merged
Conversation
Reuse the existing TLS-only, one-shot fallback when a probe returns a 401 without WWW-Authenticate. Retry the original request, preserving its method and payload; keep the original error for unsafe probes. Fixes python-caldav#717. Regression tests were added before changing the client: two new cases failed, two safety controls passed. The final client suites pass 286 tests with two skips; scoped Ruff checks pass. AI assistance: OpenAI Codex selected this reported bug, implemented and reviewed the patch, and ran the tests under the user's instruction to contribute focused fixes. No personal human review is claimed. Commands used for reproduction and validation: PYTHON_CALDAV_TEST_DOCKER=0 PYTHON_CALDAV_TEST_EXTERNAL=0 .venv/bin/pytest tests/test_async_davclient.py -k 'connection_abort_probe' -q PYTHON_CALDAV_TEST_DOCKER=0 PYTHON_CALDAV_TEST_EXTERNAL=0 .venv/bin/pytest tests/test_async_davclient.py tests/test_caldav_unit.py -q .venv/bin/ruff check caldav/async_davclient.py tests/test_async_davclient.py .venv/bin/ruff format --check caldav/async_davclient.py tests/test_async_davclient.py Assisted-By: OpenAI Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #717.
After an unauthenticated connection abort, a probe returning a bare 401 could never reach the existing Basic-auth fallback. Reuse its TLS and one-shot guards in the probe path, then retry the original request with its method, body and headers intact.
The regression tests cover successful and rejected retries, plain HTTP, an HTTPS-to-HTTP probe redirect, and a probe returning 200. Unsafe probes still re-raise the original connection error; a rejected Basic guess raises AuthorizationError and clears the guessed auth.
Validation: the two retry cases fail before the fix. The final async and synchronous client suites pass 286 tests with two skips. Ruff 0.15.20 lint and formatting pass for the changed Python files. No live server was used.
AI assistance: OpenAI Codex selected this reported issue, wrote and reviewed the patch, and ran the tests under the user's instruction to contribute focused fixes. This has not received a separate human code review. The commit includes the validation commands and an Assisted-By trailer as requested by the AI policy.