[13.x] Fix failed job providers crashing on corrupted payloads#59748
Closed
bipinks wants to merge 1 commit intolaravel:13.xfrom
Closed
[13.x] Fix failed job providers crashing on corrupted payloads#59748bipinks wants to merge 1 commit intolaravel:13.xfrom
bipinks wants to merge 1 commit intolaravel:13.xfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_decodereturnsnull,null['uuid']throws aTypeErroron PHP 8+, the exception propagates out ofWorker::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:
FileFailedJobProvider— storesnullas the id; the JSON file tolerates it.DatabaseUuidFailedJobProvider— generates a fallbackStr::uuid()so theNOT NULLconstraint onfailed_jobs.uuidisn't violated.DynamoDbFailedJobProvider— same fallback, since DynamoDB'S'attributes can't benull.Tests
Added RED-verified tests for each provider covering three corruption shapes: unparseable JSON, JSON that decodes to a scalar, and JSON missing the
uuidkey. All 212tests/Queue/*tests continue to pass.