Skip to content

Conversation

@divyanshu-tiwari
Copy link
Contributor

This PR adds a context key node_index to the output records of the Xpath task. Node index is the order in which the node matched and were processed by the xpath task.

  • helps with tracking which container element the data was extracted from
  • useful for maintaining order or grouping related data

- helps with tracking which container element the data was extracted from
- useful for maintaining order or grouping related data
Copilot AI review requested due to automatic review settings October 7, 2025 09:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a context variable node_index to the XPath task to track the order in which container nodes are processed, providing better data extraction capabilities for maintaining order and grouping related data.

  • Adds 1-based node indexing to the XPath task output
  • Updates documentation to explain the new context variable functionality
  • Includes test cases demonstrating usage with and without node indexing

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/pkg/pipeline/task/xpath/xpath.go Implements node_index context variable generation in the main XPath processing loop
internal/pkg/pipeline/task/xpath/README.md Documents the new node_index context variable and updates examples
test/pipelines/xpath_with_index.yaml Test pipeline demonstrating node_index usage with jq transformation
test/pipelines/xpath.yaml Basic XPath test pipeline without node indexing
test/pipelines/sample.html Sample HTML file for testing XPath extraction

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

if len(data) != 0 {
index := fmt.Sprintf("%d", i+1)
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Consider using strconv.Itoa(i+1) instead of fmt.Sprintf for integer to string conversion as it's more efficient for simple integer formatting.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@hladush hladush left a comment

Choose a reason for hiding this comment

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

LGTM

@divyanshu-tiwari divyanshu-tiwari merged commit b8062af into main Oct 8, 2025
5 checks passed
@divyanshu-tiwari divyanshu-tiwari deleted the xpath-node-index branch October 8, 2025 06:20
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.

4 participants