Skip to content

[13.x] Fix failed job providers crashing on corrupted payloads#59748

Closed
bipinks wants to merge 1 commit intolaravel:13.xfrom
bipinks:fix/failed-job-corrupted-payload
Closed

[13.x] Fix failed job providers crashing on corrupted payloads#59748
bipinks wants to merge 1 commit intolaravel:13.xfrom
bipinks:fix/failed-job-corrupted-payload

Conversation

@bipinks
Copy link
Copy Markdown
Contributor

@bipinks bipinks commented Apr 17, 2026

Closes #59635.

Problem

The three UUID-based failed job providers call json_decode($payload, true)['uuid'] with no guard. If the queue backend ever delivers a corrupted / non-JSON payload (Redis network corruption, truncated SQS body, custom driver bug), json_decode returns null, null['uuid'] throws a TypeError on PHP 8+, the exception propagates out of Worker::logFailedJob, and the failed job record is never written.

The safety net for jobs that fall through the cracks has a hole — the job disappears silently with no retry button and no audit trail.

Fix

Decode defensively in each provider:

$decoded = json_decode($payload, true);
$uuid = is_array($decoded) ? ($decoded['uuid'] ?? null) : null;
  • FileFailedJobProvider — stores null as the id; the JSON file tolerates it.
  • DatabaseUuidFailedJobProvider — generates a fallback Str::uuid() so the NOT NULL constraint on failed_jobs.uuid isn't violated.
  • DynamoDbFailedJobProvider — same fallback, since DynamoDB 'S' attributes can't be null.

Tests

Added RED-verified tests for each provider covering three corruption shapes: unparseable JSON, JSON that decodes to a scalar, and JSON missing the uuid key. All 212 tests/Queue/* tests continue to pass.

If a corrupted or non-JSON payload reaches a failed job provider,
json_decode($payload, true)['uuid'] throws a TypeError in PHP 8+,
propagates out of Worker::logFailedJob, and the failure record is
never persisted — silently losing both the job and the audit trail.

Make the three UUID-based providers tolerate malformed payloads:

- FileFailedJobProvider: stores null id (file storage tolerates it).
- DatabaseUuidFailedJobProvider / DynamoDbFailedJobProvider: generate
  a fallback Str::uuid() so the NOT NULL / DynamoDB 'S' attribute
  constraint is never violated.

Refs laravel#59635.
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.

Failed job providers crash on corrupted payload, losing the failure record

2 participants