[Bounty proposal] fix(database): sanitize inputs and add stream error boundaries to batch pipeline privacy queries ($50 proposed)
Problem Description
The batch privacy query layer (backend/database/batch_pipeline_privacy_queries.py) executes bounded Firestore queries for retention, segment artifact lifecycles, and user data purge flows across batch jobs. However, it currently has several input sanitization, error resilience, and testability shortcomings:
- Unsanitized Query Parameters:
namespace,table,key, andsegment_idare directly concatenated into collection names (e.g.client.collection(f'{namespace}_{table}')) without whitespace stripping or non-empty validation. Leading/trailing whitespace or empty strings produce malformed collection paths. - Unprotected Stream Queries:
owner_documents,predecessor_documents,segment_artifacts, anddue_artifactscall.stream()outside of any error boundary. Transient Firestore network timeouts or service contention crash retention workers with unhandled exceptions instead of returning[]. - Missing Client Injection Fallback: Functions require caller-supplied
clientwithoutget_firestore_client()fallback when omitted or None. - Limit Validation: In
owner_documents,limitis hardcoded to 100 rather than accepting an optional clamped boundmax(1, min(100, limit)). - Zero Dedicated Unit Tests:
backend/database/batch_pipeline_privacy_queries.pycurrently has zero dedicated unit tests inbackend/tests/unit/test_batch_pipeline_privacy_queries.py.
Proposed Solution
- Parameter Sanitization: Strip
namespace,table,key, andsegment_idacross all query builders, returning[]on empty/None parameters. - Stream Error Boundaries: Wrap all collection stream queries in
try/except Exceptionboundaries, logging warnings and safely returning[]. - Firestore Client Fallback: Inject
get_firestore_client()whenclientis None. - Bounded Limits: Clamp limits with
max(1, min(100, limit))safely. - Comprehensive Unit Tests: Add 16 dedicated unit test functions (35 test assertions) in
backend/tests/unit/test_batch_pipeline_privacy_queries.pyverifying collection naming, query construction, cursor handling, input validation, and exception handling.
Proposed Bounty: $50 PayPal: https://paypal.me/Dragonire9 ([email protected])
Hi @josancamon19 @kodjima33 — is there still a paid scope for the complete #21916 repair beyond the work in #21928, with #21917 now closed unmerged?
I mean the full result: identifier sanitization, all four stream error boundaries, Firestore client fallback, bounded limits, and the requested 16 tests/35 assertions covering query construction and cursor/error cases. If work remains, which revision and acceptance checks should I use, and should I coordinate with the current contributor?
The issue proposes $50 but has no Paid Bounty label. Could you confirm the approved cash amount and currency, and whether you can pay a mainland-China individual in the same legal name — through which permitted method, with what fees and timing?
Once scope and payment are clear, I can check the complete implementation and give a delivery estimate.
Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏