Skip to content

[ Queue ] Handle malformed job payloads safely - legacy queue records#3499

Open
nhatghost wants to merge 1 commit into
orchestration-agent:mainfrom
nhatghost:fix-legacy-queue-records
Open

[ Queue ] Handle malformed job payloads safely - legacy queue records#3499
nhatghost wants to merge 1 commit into
orchestration-agent:mainfrom
nhatghost:fix-legacy-queue-records

Conversation

@nhatghost
Copy link
Copy Markdown

Description

This PR addresses Issue #3484 by implementing robust validation, decoding, and auditing safeguards on TaskScheduler when receiving legacy queue records, protecting the orchestrator pipeline from malformed inputs.

Key Enhancements

  1. Robust Legacy Decoders: Introduced enqueue_legacy_record() which decodes inputs (JSON string/bytes/dicts) and systematically verifies critical identifiers (legacy_id, job_id, id) and payload schemas.
    1. Idempotency Guard: Tracks already-enqueued legacy records using self._legacy_ids to deduplicate and prevent double-execution, returning the original task_id for deduplicated events.
    1. Audit Log & Leakage Prevention: Records malformed payloads inside _queue_audit safely omitting raw credentials to prevent sensitive information leakages.
    1. Rigorous Tests: Added tests/test_legacy_queue_records.py covering malformed record rejection, bad payload safe handling, idempotency, and task type enforcement.
    1. Resolved Deadlocks & Windows compatibility: Applied conditional resource imports and reentrant locking (RLock) in metrics to ensure clean local development environments. All unit tests pass cleanly!

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