Skip to content

fix: error nicely when a task is not found - #148

Merged
bojanz merged 2 commits into
mainfrom
task-not-found
Aug 11, 2026
Merged

fix: error nicely when a task is not found#148
bojanz merged 2 commits into
mainfrom
task-not-found

Conversation

@vitolkachova

Copy link
Copy Markdown
Contributor

Instead of RequestException

Copilot AI lite review requested due to automatic review settings August 11, 2026 11:14
@upsun-dispatch

upsun-dispatch Bot commented Aug 11, 2026

Copy link
Copy Markdown

📋 PR Summary

Improves the task:run command so that a missing task, or an environment with no tasks, produces a clear message instead of a raw Guzzle RequestException. The task argument becomes optional (offering an interactive numbered chooser when omitted), a new Api::getEnvironmentTasks() helper centralizes fetching tasks keyed by name, and TaskListCommand is refactored to use it. Integration tests cover the run, choose, not-found, non-interactive, and no-tasks paths.

Changes
Layer / File(s) Summary
task commands
legacy/src/Command/Task/TaskRunCommand.php Makes the task argument optional, handles the empty-task-list case first, adds an interactive chooser (with a summarizeCommand helper for one-line display), and emits a friendly not-found message with a hint to list tasks.
legacy/src/Command/Task/TaskListCommand.php Uses the new Api::getEnvironmentTasks() helper instead of fetching tasks inline, iterating by name key, and drops the now-unused Guzzle/ApiResponseException imports.
api service
legacy/src/Service/Api.php Adds getEnvironmentTasks() which fetches the tasks endpoint, converts BadResponseException to ApiResponseException, and returns tasks keyed by name.
tests
integration-tests/task_test.go Expands TaskRun tests (multi-line command summary, chooser, non-interactive, not-found) and TaskRunNoTasks to cover both explicit-name and no-argument cases; tracks which task ran via atomic.Value.

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Reviewed — No new blocking findings · 1 minor point

🔍 Full review · 4 files reviewed

🔵 Minor points

Not blocking, and no threads opened for these.

  • legacy/src/Service/Api.php:1844 — When a task object in the API response lacks a 'name' key, getEnvironmentTasks keys it by the numeric list index ($task['name'] ?? $key), and TaskListCommand now renders that key as the Name column value. The previous list code produced an empty Name ($task['name'] ?? '') in that case, so name-less tasks now display a numeric index instead of blank.
Review details
  • Commit: 212f5f8
  • Model: claude-opus-4-8
  • Panel: correctness · robustness · design

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the legacy PHP task:run command UX by proactively checking whether a task exists on the selected environment and emitting a clear, actionable error message instead of surfacing a low-level RequestException. It also centralizes task-list fetching in the legacy API service and adds integration coverage to prevent regressions.

Changes:

  • Added Api::getEnvironmentTasks() to fetch and return environment tasks keyed by name.
  • Updated task:list and task:run to use the shared task-fetching helper; task:run now prints a friendly “task not found” / “no tasks” message and exits early.
  • Added integration tests covering list, run, missing-task, and no-tasks scenarios.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
legacy/src/Service/Api.php Adds a reusable helper to fetch tasks for an environment and key them by task name.
legacy/src/Command/Task/TaskRunCommand.php Checks task existence before attempting run; improves stderr messaging and avoids RequestException output.
legacy/src/Command/Task/TaskListCommand.php Uses the new API helper and adjusts iteration to use task names as keys.
integration-tests/task_test.go Adds integration tests validating task list/run behavior and improved “not found” messaging.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bojanz
bojanz self-requested a review August 11, 2026 11:27
@bojanz
bojanz merged commit 66a8c8c into main Aug 11, 2026
6 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.

3 participants