Conversation
Pass includeData=true to the n8n API when the --data flag is set, and display a per-node summary showing status, item counts, and execution time.
Summary of ChangesHello @Hinne1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a --data flag to the n8nctl execution view command, enabling users to see a per-node execution summary. The changes are well-implemented, including updates to the API client to fetch the necessary data and new functions to parse and display it. My review includes a couple of suggestions to enhance code maintainability and improve the command-line output's consistency.
| fmt.Printf("\nNode Execution Data:\n") | ||
| fmt.Printf("────────────────────\n") | ||
|
|
||
| for nodeName, nodeRuns := range runData { |
There was a problem hiding this comment.
The iteration order for maps in Go is not guaranteed. To ensure a consistent and deterministic output for the nodes, it's best to sort the node names alphabetically before iterating and printing the data.
You'll need to import the sort package for this.
nodeNames := make([]string, 0, len(runData))
for nodeName := range runData {
nodeNames = append(nodeNames, nodeName)
}
sort.Strings(nodeNames)
for _, nodeName := range nodeNames {
nodeRuns := runData[nodeName]
// ... rest of the loop
}| input = -1 | ||
| output = -1 | ||
|
|
||
| // Input items from inputData | ||
| if inputData, ok := run["inputData"].(map[string]interface{}); ok { | ||
| if main, ok := inputData["main"].([]interface{}); ok { | ||
| input = 0 | ||
| for _, branch := range main { | ||
| if items, ok := branch.([]interface{}); ok { | ||
| input += len(items) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Output items from data.main | ||
| if data, ok := run["data"].(map[string]interface{}); ok { | ||
| if main, ok := data["main"].([]interface{}); ok { | ||
| output = 0 | ||
| for _, branch := range main { | ||
| if items, ok := branch.([]interface{}); ok { | ||
| output += len(items) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return |
There was a problem hiding this comment.
The countItems function has duplicated logic for counting input and output items. This can be refactored by extracting the common counting logic into a local helper function to improve readability and maintainability.
input = -1
output = -1
countBranchItems := func(main []interface{}) int {
count := 0
for _, branch := range main {
if items, ok := branch.([]interface{}); ok {
count += len(items)
}
}
return count
}
// Input items from inputData
if inputData, ok := run["inputData"].(map[string]interface{}); ok {
if main, ok := inputData["main"].([]interface{}); ok {
input = countBranchItems(main)
}
}
// Output items from data.main
if data, ok := run["data"].(map[string]interface{}); ok {
if main, ok := data["main"].([]interface{}); ok {
output = countBranchItems(main)
}
}
return
Summary
--dataflag ton8nctl execution viewthat passesincludeData=trueto the n8n API--data --json) includes the fulldatafield automaticallyTest plan
n8nctl execution view 4912956— works as before (no data)n8nctl execution view 4912956 --data— shows per-node summary (15 nodes, all success)n8nctl execution view 4912956 --data --json— includes full data field in JSONgo build ./...— compiles without errors