feat: add task result retrieval for workflow executions#72
Merged
discostu105 merged 6 commits intodynatrace-oss:mainfrom Mar 18, 2026
Merged
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #72 +/- ##
=======================================
Coverage ? 38.64%
=======================================
Files ? 162
Lines ? 16345
Branches ? 0
=======================================
Hits ? 6317
Misses ? 9606
Partials ? 422 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add GET /platform/automation/v1/executions/{id}/tasks/{taskName}/result
support to surface the return value of individual tasks (e.g. the object
returned by a JavaScript task's default export function).
Changes:
- pkg/resources/workflow/execution.go: add GetTaskResult() method
- cmd/logs.go: add --result flag to 'logs wfe --task <name> --result'
- cmd/exec_workflows.go: add --show-results flag to 'exec workflow --wait'
Usage:
# Fetch the return value of a specific task
dtctl logs wfe <execution-id> --task <task-name> --result
# Execute workflow and show all task return values on completion
dtctl exec workflow <id> --wait --show-results
Fixes: without this, the only way to retrieve JavaScript task output was
to hit the automation REST API directly with curl/Bearer token.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove --result flag from 'logs wfe' (logs = stdout/stderr; results = structured return values — semantically distinct) - Add new 'dtctl results workflow-execution' command (alias: wfe) with required --task flag and -o json/yaml output support - Add --show-results flag to 'exec workflow --wait' for convenience - Update QUICK_START.md with both new commands Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per feedback in dynatrace-oss#71, move task result retrieval from the 'results' top-level command group to 'get wfe-task-result', consistent with existing patterns where 'get' is the verb for reading resources. Before: dtctl results wfe <execution-id> --task <task-name> After: dtctl get wfe-task-result <execution-id> --task <task-name> dtctl get workflow-execution-task-result <execution-id> --task <task-name> This mirrors the existing 'dtctl logs wfe' / 'dtctl get wfe' relationship and maps directly to the API endpoint (.../result), leaving no ambiguity between task results and task metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Trim verbose godoc and Long description to match repo conventions - Fix QUICK_START.md: update commands from 'results wfe' to 'get wfe-task-result' - Add unit tests for GetTaskResult and ListTasks (table-driven, httptest) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8c4745d to
b5f7982
Compare
Contributor
Author
|
Updated PR based on your feedback @discostu105 . Please have another look. |
- Fix test indentation (was flush-left, now properly tabbed) - Add agent envelope support to get wfe-task-result (enrichAgent + suggestions) - Validate --show-results requires --wait (PreRunE check) - Eliminate N+1 API calls in --show-results: use task.Result from ListTasks instead of calling GetTaskResult per task - Move examples from Long to Example field in Cobra commands - Fix help text grouping: place wfe-task-result near workflow-executions
- In agent mode (-A), exec workflow now produces a single structured JSON envelope instead of mixing fmt.Printf with printer output - Extract helper functions (execWorkflowWait, execWorkflowShowResults, execWorkflowAgent) for clarity and to separate human/agent code paths - Add enrichAgent call with verb=exec, resource=workflow, plus suggestions and duration context - Add TestListTasks_WithResults to verify Result field deserialization (used by --show-results to avoid N+1 API calls)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #71
What this PR does
Adds support for reading the return value of individual task executions via the
GET /platform/automation/v1/executions/{id}/tasks/{taskName}/resultendpoint.Changes
pkg/resources/workflow/execution.goGetTaskResult(executionID, taskName string) (any, error)— thin wrapper around the task result API endpoint, consistent with the existingGetTaskLog()pattern.cmd/get_wfe_task_result.go— newgetsub-resourceRequires
--task. Respects-o json/yaml/tablevia the standardPrinter.Per feedback in #71, this lives under
get(not a separateresultsverb) to stay consistent with existing patterns likedtctl get wfeanddtctl logs wfe.cmd/exec_workflows.go— new--show-resultsflagAfter the workflow completes, lists all tasks and prints each task's return value. Only valid with
--wait.docs/QUICK_START.md--show-resultsexample under Execute Workflowsget wfe-task-resultexamplespkg/resources/workflow/execution_test.goGetTaskResult(success, 404, 500) using the repo'snewExecTestHandlerpatternExample output