ctengel / ctengel/simpler-objects

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

Open
#70 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

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 `. 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.