Skip to content

Comments

Add --data flag to execution view#1

Open
Hinne1 wants to merge 2 commits intomainfrom
claude/execution-view-data
Open

Add --data flag to execution view#1
Hinne1 wants to merge 2 commits intomainfrom
claude/execution-view-data

Conversation

@Hinne1
Copy link
Contributor

@Hinne1 Hinne1 commented Feb 4, 2026

Summary

  • Adds --data flag to n8nctl execution view that passes includeData=true to the n8n API
  • Displays a per-node execution summary showing status, item counts (input/output), and execution time in ms
  • JSON output (--data --json) includes the full data field automatically

Test 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 JSON
  • go build ./... — compiles without errors

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.
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 n8nctl execution view command by introducing a --data flag. This flag enables users to retrieve and display granular, per-node execution details directly within the command-line interface, providing insights into status, item flow, and performance for each step of a workflow. It also ensures that this rich data is properly included when requesting JSON output.

Highlights

  • API Client Update: The GetExecution function in the API client has been updated to accept an includeData boolean parameter, allowing the client to request detailed execution data from the n8n API.
  • CLI view Command Enhancement: A new --data flag has been added to the n8nctl execution view command. When this flag is used, the command fetches and displays a per-node summary of the execution.
  • Per-Node Execution Summary: New logic has been implemented to parse and present a detailed summary for each node within an execution. This summary includes the node's status (success/error), input and output item counts, and execution time in milliseconds.
  • JSON Output Integration: When the --data flag is combined with the --json flag, the full data field, containing all the detailed execution information, is automatically included in the JSON output.
Changelog
  • internal/api/client.go
    • Modified GetExecution function signature to include an includeData boolean parameter.
    • Conditionally appends ?includeData=true to the API request path if includeData is true.
  • internal/cmd/execution/execution.go
    • Added a showData boolean variable to control data display.
    • Updated the call to client.GetExecution to pass the showData flag.
    • Introduced a new --data flag for the view command, which sets showData.
    • Implemented printNodeData function to format and display per-node execution summaries.
    • Added countItems helper function to extract input and output item counts from node run data.
Activity
  • The author, Hinne1, initiated this pull request to introduce the --data flag to the n8nctl execution view command.
  • The pull request description includes a clear summary of the changes and a comprehensive test plan, demonstrating the new functionality and ensuring existing behavior remains intact.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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 {

Choose a reason for hiding this comment

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

medium

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
	}

Comment on lines +317 to +344
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

Choose a reason for hiding this comment

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

medium

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

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.

1 participant