Skip to content

Fix TypeError when editing queued job with invalid JSON payload#468

Merged
dereuromark merged 1 commit intomasterfrom
fix/json-validation-error
Mar 28, 2026
Merged

Fix TypeError when editing queued job with invalid JSON payload#468
dereuromark merged 1 commit intomasterfrom
fix/json-validation-error

Conversation

@dereuromark
Copy link
Copy Markdown
Owner

Summary

  • When invalid JSON is submitted via the data edit form (/admin/queue/queued-jobs/data/{id}), the JsonableBehavior threw a TypeError because json_decode returned null but the return type was array
  • Now shows a proper flash error message (e.g., "Invalid JSON: Syntax error") and preserves the user's invalid input so they can fix it

Changes

  • Update _fromJson() in JsonableBehavior to throw InvalidArgumentException with a descriptive error message instead of TypeError
  • Catch the exception in data() action and show a flash error
  • Preserve the user's invalid input so they can fix it
  • Add test for invalid JSON handling

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 28, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 63.15789% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.16%. Comparing base (4de7db1) to head (07bb9a7).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/Controller/Admin/QueuedJobsController.php 87.50% 1 Missing ⚠️
src/Queue/Task/CostsExampleTask.php 0.00% 1 Missing ⚠️
src/Queue/Task/MonitorExampleTask.php 0.00% 1 Missing ⚠️
src/Queue/Task/ProgressExampleTask.php 0.00% 1 Missing ⚠️
src/Queue/Task/RetryExampleTask.php 0.00% 1 Missing ⚠️
src/Queue/Task/SuperExampleTask.php 0.00% 1 Missing ⚠️
src/Queue/Task/UniqueExampleTask.php 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #468      +/-   ##
============================================
+ Coverage     77.03%   77.16%   +0.12%     
- Complexity      936      938       +2     
============================================
  Files            45       45              
  Lines          3166     3184      +18     
============================================
+ Hits           2439     2457      +18     
  Misses          727      727              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dereuromark dereuromark force-pushed the fix/json-validation-error branch from 4ffea6d to 42a156e Compare March 28, 2026 12:46
When invalid JSON is submitted via the data edit form, the
JsonableBehavior threw a TypeError because json_decode returned null
but the return type was array.

Changes:
- Update _fromJson() to throw InvalidArgumentException with a
  descriptive error message instead of TypeError
- Catch the exception in data() action and show a flash error
- Preserve the user's invalid input so they can fix it
- Add data_string virtual property annotation to QueuedJob entity
- Add test for invalid JSON handling
- Fix PHPStan errors: handle nullable description() in example tasks
@dereuromark dereuromark force-pushed the fix/json-validation-error branch from 42a156e to 07bb9a7 Compare March 28, 2026 12:54
@dereuromark dereuromark merged commit 697206e into master Mar 28, 2026
22 of 24 checks passed
@dereuromark dereuromark deleted the fix/json-validation-error branch March 28, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants