Skip to content

Fix loaded relation index lookups in StoredWorkflow#361

Merged
rmcdaniel merged 2 commits intomasterfrom
fix/replace-first-where
Mar 20, 2026
Merged

Fix loaded relation index lookups in StoredWorkflow#361
rmcdaniel merged 2 commits intomasterfrom
fix/replace-first-where

Conversation

@rmcdaniel
Copy link
Member

Summary

Replace firstWhere('index', ...) lookups on loaded logs and timers relations with direct raw-attribute checks.

Prevent replay paths from ever treating index like an Eloquent relation/method, which matches the reported StoredWorkflowLog::index() failure.

Add regression coverage to ensure loaded relation lookups do not fall back to firstWhere() again.

Why

The reported crash happens while replaying workflow state for child/activity stubs. The stack trace points at findLogByIndex(), and the risky part was the in-memory lookup against an already-loaded Eloquent collection. This change hardens that path and the equivalent timer lookup as well.

I couldn’t reproduce the exact exception but this fixes the code path implicated by the report and adds tests to keep it from regressing.

Fixes #360

@rmcdaniel rmcdaniel merged commit 68e47cd into master Mar 20, 2026
1 check passed
@rmcdaniel rmcdaniel deleted the fix/replace-first-where branch March 20, 2026 02:00
@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1785f13) to head (d9d19d9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##              master      #361   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       577       579    +2     
===========================================
  Files             62        62           
  Lines           2003      2007    +4     
===========================================
+ Hits            2003      2007    +4     

☔ 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.

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.

BadMethodCallException: Call to undefined method Workflow\Models\StoredWorkflowLog::index() in ChildWorkflowStub

2 participants