Skip to content

Fix: pass RunTemplate object instead of int to prepareJob()#27

Merged
Vitexus merged 2 commits intomainfrom
fix/runtemplate-schedule-type-error
Mar 1, 2026
Merged

Fix: pass RunTemplate object instead of int to prepareJob()#27
Vitexus merged 2 commits intomainfrom
fix/runtemplate-schedule-type-error

Conversation

@Vitexus
Copy link
Member

@Vitexus Vitexus commented Mar 1, 2026

The runtemplate schedule action was passing $rt->getMyKey() (int) to Job::prepareJob() which expects a RunTemplate object as its first argument, causing a PHP Fatal TypeError on every schedule attempt.

Summary by CodeRabbit

  • Refactor

    • Enhanced template object handling in job preparation workflow
  • Chores

    • Added documentation to improve code clarity

The schedule action was passing $rt->getMyKey() (int) to Job::prepareJob() which expects a RunTemplate object as its first argument.

Co-Authored-By: Oz <oz-agent@warp.dev>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

The RunTemplate scheduling path modified to pass the complete RunTemplate object to Job::prepareJob instead of only its key identifier. A descriptive docblock was added to the execute method for documentation clarity.

Changes

Cohort / File(s) Summary
Job Preparation Update
src/Command/RunTemplateCommand.php
Modified Job::prepareJob invocation to pass the RunTemplate object directly rather than just its key; added execute method docblock for improved code documentation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A template hops along with care,
Now passes itself through the air,
No keys held tight, but whole and true,
The job prepares with fresh new view,
With docs so bright, the path is clear! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change in the PR: fixing a type error by passing a RunTemplate object instead of an integer key to the prepareJob() method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/runtemplate-schedule-type-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings and committed to branch fix/runtemplate-schedule-type-error (commit: c14d4b6e19cb6a500ae3b42fcc3252b7238391b8)

Docstrings generation was requested by @Vitexus.

The following files were modified:

* `src/Command/RunTemplateCommand.php`
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Command/RunTemplateCommand.php`:
- Around line 577-578: The assignment to $prepared is unused — call prepareJob
with the RunTemplate ($rt) and other args without assigning its return value;
remove the unused $prepared variable and keep the existing call to
$jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor,
$scheduleType) (note: scheduleJobRun() is invoked inside prepareJob()).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0df4ae and c14d4b6.

📒 Files selected for processing (1)
  • src/Command/RunTemplateCommand.php

Comment on lines +577 to 578
$prepared = $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType);
// scheduleJobRun() is now called automatically inside prepareJob()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Correct fix, but remove unused variable assignment.

The fix correctly passes the RunTemplate object instead of its integer key, resolving the TypeError. However, the $prepared variable is assigned but never used.

🧹 Proposed fix to remove unused variable
-                    $prepared = $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType);
+                    $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$prepared = $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType);
// scheduleJobRun() is now called automatically inside prepareJob()
$jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType);
// scheduleJobRun() is now called automatically inside prepareJob()
🧰 Tools
🪛 PHPMD (2.15.0)

[warning] 577-577: Avoid unused local variables such as '$prepared'. (undefined)

(UnusedLocalVariable)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Command/RunTemplateCommand.php` around lines 577 - 578, The assignment to
$prepared is unused — call prepareJob with the RunTemplate ($rt) and other args
without assigning its return value; remove the unused $prepared variable and
keep the existing call to $jobber->prepareJob($rt, $overridedEnv,
$scheduleDateTime, $executor, $scheduleType) (note: scheduleJobRun() is invoked
inside prepareJob()).

@Vitexus Vitexus merged commit 470db1d into main Mar 1, 2026
1 of 2 checks passed
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