Skip to content

fix: roll back auth on restricted-bucket failure, correct an assert message, guard args, parse the pydantic version, and fix part-size mapping - #719

Merged
ffumero2003 merged 2 commits into
masterfrom
fix-python-low-audit-api-http-types-bucket
Nov 21, 2026
Merged

ffumero2003 merged 2 commits into
masterfrom
fix-python-low-audit-api-http-types-bucket

Conversation

@ffumero2003

Copy link
Copy Markdown
Contributor

Context

Address C55, C28, C51, C31, and C33 from the low-severity audit.

Root cause

Authorization persisted credentials before checking deleted-bucket restrictions. The remaining defects were an incorrect assertion interpolation, unchecked exception argument indexes, a lexical version comparison, and a minimum part size forwarded as the recommended size.

Changes

  • Reject deleted-bucket restrictions before changing authentication data or caches, including the separate legacy authorization path. Existing sessions remain intact; fresh sessions remain unauthenticated.
  • Show the returned bucket name in creation mismatch diagnostics.
  • Guard missing outer and nested connection-error arguments while retaining existing error mappings.
  • Compare the optional Pydantic major version numerically.
  • Forward Bucket.upload(min_part_size=...) to the planner's minimum and clarify the docstring.
  • Promote the existing regressions, expand boundary coverage, and add five towncrier fragments.

Verification

Each finding was observed red before its production fix, then green. A separate pristine archive of master dd366eb3, with only the final regression tests overlaid, also reproduces all five findings: 17 failed, 4 passed. The identical focused v3 selection on this branch is 21 passed:

pytest --api=v3 test/unit/bucket/test_regression_bucket.py test/unit/test_regression_misc.py test/unit/test_session.py -k 'c55 or c28 or c51 or c31 or c33' -q

Full unit suites and doctests on Python 3.13.15, using pytest --api=<version> --doctest-modules -n 4 test/unit -q --tb=short:

API Passed Skipped Existing expected failures
v3 1273 77 15
v2 1278 84 13
v1 1303 174 5
v0 1143 459 5
  • ruff check b2sdk test noxfile.py: passed.
  • ruff format --check on all nine changed Python files: passed.
  • python -m nox --no-venv -s towncrier_check: passed.
  • git diff --check: passed.
  • Localhost harness tests require execution outside the restricted sandbox; the full suite results above include them.
  • pytest test/static: 64 passed, 2 failed from existing strict XPASS markers for already-fixed C30/C59. The same two failures are present in master's CI. Whole-repository format checking also flags unchanged master noxfile.py; these unrelated files are untouched.
  • Live B2 integration tests were not run.

Refs #711

@ffumero2003 ffumero2003 self-assigned this Nov 21, 2026
@ffumero2003
ffumero2003 requested a review from goanpeca November 21, 2026 22:59
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0f2da09-d345-442c-8dc2-a95434bc132c
Commits

Reviewing files that changed from the base of the PR and between be0814d and 0a1bdf4.

Files selected for processing: 14

  • b2sdk/_internal/api.py
  • b2sdk/_internal/b2http.py
  • b2sdk/_internal/bucket.py
  • b2sdk/_internal/session.py
  • b2sdk/_internal/types.py
  • b2sdk/v1/session.py
  • changelog.d/+c28-bucket-assert.fixed.md
  • changelog.d/+c31-pydantic-version.fixed.md
  • changelog.d/+c33-upload-part-size.fixed.md
  • changelog.d/+c51-http-error-args.fixed.md
  • changelog.d/+c55-auth-session.fixed.md
  • test/unit/bucket/test_regression_bucket.py
  • test/unit/test_regression_misc.py
  • test/unit/test_session.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@ffumero2003
ffumero2003 merged commit 2e316e6 into master Nov 21, 2026
28 of 29 checks passed
@ffumero2003
ffumero2003 deleted the fix-python-low-audit-api-http-types-bucket branch November 21, 2026 23:34
ffumero2003 added a commit that referenced this pull request Nov 21, 2026
…722)

Merging the low-severity fixes (#716, #719) converted known-defect tests
to ordinary assertions but left test.known_defect imports unused, failing
ruff (F401) on master. Import only the names each module still uses.

Refs #711
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.

1 participant