Skip to content

fix: allow safe Basic auth after async connection-abort probes - #721

Merged
tobixen merged 1 commit into
python-caldav:masterfrom
natesute:fix/async-auth-probe
Oct 3, 2026
Merged

tobixen merged 1 commit into
python-caldav:masterfrom
natesute:fix/async-auth-probe

Conversation

@natesute

Copy link
Copy Markdown
Contributor

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.

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
@tobixen
tobixen merged commit a6b5017 into python-caldav:master Oct 3, 2026
11 checks passed
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.

Async client: issue-158 connection-abort probe never reaches the #713 unprompted-basic guess

2 participants