Skip to content

feat: add task list command (from #742) - #744

Open
NickJosevski wants to merge 6 commits into
mainfrom
justin-newman-742
Open

NickJosevski wants to merge 6 commits into
mainfrom
justin-newman-742

Conversation

@NickJosevski

Copy link
Copy Markdown
Contributor

From: #742

Adds 'octopus task list' to list server tasks, filtered by project,
environment (including ephemeral environments) and state. Output
supports table, json and basic formats, where basic prints task IDs
so the result can be piped into 'octopus task wait'.

Previously tasks could only be waited on by ID, so automation had to
call the REST API to discover in-flight deployments and runbook runs.

Adds 'octopus task list' to list server tasks, filtered by project,
environment (including ephemeral environments) and state. Output
supports table, json and basic formats, where basic prints task IDs
so the result can be piped into 'octopus task wait'.

Previously tasks could only be waited on by ID, so automation had to
call the REST API to discover in-flight deployments and runbook runs.
@NickJosevski NickJosevski changed the title Justin newman 742 feat: add task list command (from #742) Oct 9, 2026
Comment thread pkg/cmd/task/list/list.go
Comment on lines +198 to +208
environment, err := selectors.FindEnvironment(octopus, nameOrID)
if err == nil {
return environment.GetID(), nil
}

ephemeralEnvironment, ephemeralErr := util.GetByName(octopus, nameOrID, octopus.GetSpaceID())
if ephemeralErr == nil {
return ephemeralEnvironment.ID, nil
}

return "", fmt.Errorf("no environment or ephemeral environment found with name of %s", nameOrID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

resolveEnvironmentID throws away both lookup errors. It reports no environment or ephemeral environment found whether the lookups returned not-found or something else.

  • Misleading message: If FindEnvironment fails for any other reason (auth/permission error, network failure, server error), the code falls through to the ephemeral lookup. If that also fails, the user sees a "not found" message even though the environment may exist.
  • Hidden cause: The real failure is hidden, which makes CI failures hard to diagnose.

Suggested fix:

  • Only fall back to the ephemeral lookup when the first error is a not-found condition.
  • Otherwise return the original error, wrapping err/ephemeralErr so the underlying cause is preserved.

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.

Thanks, agreed. Fixed on the #742 branch (justin-newman:feat/task-list) in d345e81, with a follow-up test fix in 1fc708e.

resolveEnvironmentID now looks up regular environments directly and only falls back to ephemeral environments when that lookup succeeds with no match. A failed lookup is returned wrapped with %w (failed to look up environment '<name>' or failed to look up ephemeral environment '<name>'), so the underlying cause is preserved. The generic "no environment or ephemeral environment found" message is now only used when both lookups succeed and neither matches. I did not use errors.Is for the not-found case because FindEnvironment and the ephemeral GetByName report not-found as plain fmt.Errorf strings.

Both failure paths have tests, and the unit suite passes on my fork: https://github.com/justin-newman/octopus-cli/actions/runs/37982658151

I can't push to justin-newman-742, so this needs pulling into #744 or re-creating from #742.

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