Skip to content

feat(runs): show the failure reason in task view [COMP-1655] - #747

Merged
jonmarti merged 1 commit into
masterfrom
feat/COMP-1655-task-failure-reason
Nov 16, 2026
Merged

jonmarti merged 1 commit into
masterfrom
feat/COMP-1655-task-failure-reason

Conversation

@jonmarti

@jonmarti jonmarti commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • tw runs view -i <run> task -t <task> prints a Failure reason block under the General table when Platform sends one. That is the Scheduler's reason for a failed Intelligent Compute task (seqeralabs/platform#13662), or the compute platform's message for the exit code on Google Batch.
  • It is a block, like Command, rather than a table row: Scheduler reasons run to hundreds of characters (516 in the example below), and a row would stretch the whole General table to that width.
  • For an ABORTED task the block is labelled Reason. This matches the task dialog in seqeralabs/platform#13712 (draft), which gives aborted tasks the reason they were stopped; such a task didn't fail itself. Platform doesn't send a reason for aborted tasks yet, so this label only appears once that PR is released.
  • With -o json, general.errorMessage is included whenever Platform sends it.
  • No SDK or VERSION-API bump: Task.errorMessage exists since Platform API 1.116.0 and is in SDK 1.261.0. No native-image metadata change: Task is already registered with all its declared fields and methods.

Jira: COMP-1655.

Example

A task from an Intelligent Compute run that asked for more than any instance type offers (Platform dev; rows elided):

$ tw runs view -i <run> task -t 1

     General
    ----------------+------------------------
     ...
     Status         | FAILED

     Failure reason
    ----------------
     No instance type can fit cpus=1024.0, memory=1792.0GB, gpus=0: region eu-west-1, catalog 621 -> runnable 611 -> machineTypes [c5ad, c5d, c6id, …, x2gd] 224 -> local-ssd 224

     Command
    ---------
     echo 'Bonjour world!'

Notes

  • Platform stores the Scheduler's reasons about a minute after the run ends, so a task viewed before then shows none.
  • Only tasks that failed in the Scheduler get a reason, and tasks from runs before seqeralabs/platform#13662 have none (no backfill).

Not included

  • tw runs view tasks (the task list): no new column. Platform's task list does return the reason, but at hundreds of characters it doesn't fit a table column; the task view is the place to read it.

Testing

  • New TaskCmdTest cases: the reason is shown under its heading and on its own line (not in the General table), an ABORTED task gets Reason, nothing is printed when Platform sends no reason, and the JSON has the key. They check the printed text, because the existing testTaskDetail* cases compare the output with a TaskView built by the same code.
  • The new cases fail when they should:
    • With the change reverted, the shown, ABORTED and JSON cases fail. The "none" case passes, as it should.
    • Printing the reason as a General table row fails the shown and ABORTED cases.
    • Always labelling it Failure reason fails the ABORTED case.
  • ./gradlew test --tests 'io.seqera.tower.cli.runs.TaskCmdTest': 11/11 pass. Full suite and native build left to CI.
  • Ran against Platform dev:
    • a FAILED task prints the block above;
    • an ABORTED task of the same run prints no block;
    • -o json includes general.errorMessage.

🤖 Generated with Claude Code

Platform returns why a task failed in Task.errorMessage: the
Scheduler's reason for Intelligent Compute tasks, or the exit code
message on Google Batch. tw never printed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonmarti
jonmarti requested a review from a team as a code owner November 16, 2026 11:29

@claude claude 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.

Approve: a small additive change that surfaces Task.errorMessage in runs view task, with tests covering each display branch.

What I checked

  • TaskCmd.parseGeneralData only adds errorMessage when it is non-null, so JSON output for tasks without an error stays the same. The new key is purely additive.
  • In TaskView, general.get("status") holds task.getStatus().getValue(), which is a String, so "ABORTED".equals(...) compares the right types.
  • The reason text is printed without going through ansi(). That's correct: it's free text from the server and could contain @| sequences that Jansi would otherwise read as markup. The underline width (label.length() + 2) lines up with how the existing Command and Environment headings are formatted.
  • The tests cover the FAILED label, the ABORTED label, the no-reason case, and JSON output. The new mockTaskDetail(mock, status, extra) overload leaves the old callers' behaviour unchanged.

Nits (non-blocking)

  • replaceAll("\n", ...) leaves a stray \r if the server ever sends CRLF. This matches the existing Command and Environment handling, so I'd only change it if all three are changed together.
  • testTaskDetailHidesReasonWhenNone asserts that the lowercase stdout contains no "reason" anywhere. That holds against the current fixture, but it will break if any unrelated field in task_detail.json ever contains that word. Asserting on the absence of the heading would be less brittle.

Coverage note: I couldn't inspect the tower-java-sdk 1.261.0 jar in this environment, so I haven't independently confirmed that Task#getErrorMessage() exists in the pinned SDK. The compile and test jobs on this PR (still pending as I write this) will confirm it.

@jonmarti jonmarti self-assigned this Nov 16, 2026
@jonmarti
jonmarti merged commit 57fe86d into master Nov 16, 2026
14 of 15 checks passed
@jonmarti
jonmarti deleted the feat/COMP-1655-task-failure-reason branch November 16, 2026 16:16
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.

2 participants