Skip to content

async_replicate: replace integrity asserts with explicit raises (don't rely on Python without -O) #70

Open

Description

@ctengel

The replicator (simpler_objects/async_replicate.py) uses assert for what are really integrity checks: that the source has a content-length and a Repr-Digest, that the destination is missing before we PUT, that the stream's length and digest match what we expected, and that the destination holds the right bytes after the PUT.

Under python -O (or PYTHONOPTIMIZE=1) every one of those becomes a no-op. When the replicator was a manual CLI invocation that was a footgun; now that it runs on every systemd-timer / cron firing under whatever Python the operator installed, it's worth fixing.

Suggested approach: replace the asserts in replicate_object, auto_replica, and replicate_bucket with explicit if not …: raise <appropriate error>. The places that currently assert on httpx response shape can stay defensive — they just shouldn't disappear under -O.

Surfaced by the PR #67 review.

Activity

  1. modified the milestones: Future, Performance on May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions