Skip to content

dql/xml,html: dump#2625

Merged
xushiwei merged 1 commit intogoplus:mainfrom
xushiwei:q
Feb 15, 2026
Merged

dql/xml,html: dump#2625
xushiwei merged 1 commit intogoplus:mainfrom
xushiwei:q

Conversation

@xushiwei
Copy link
Member

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @xushiwei, 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 enhances the DQL (Data Query Language) functionality for XML and HTML by introducing a dedicated debugging method, _dump, to aid in inspecting node structures. It also refines the internal handling of node sequences through updated NodeSet_Cast signatures and optimizes XML attribute and character data copying. Furthermore, a specific improvement addresses the parsing of HTML document nodes, and comprehensive test cases validate these new features and optimizations.

Highlights

  • New Debugging _dump Method: A new _dump method has been introduced for NodeSet in dql/xml and dql/html, and for Node and File types respectively, allowing developers to print node information to os.Stderr for debugging purposes.
  • Updated NodeSet_Cast Signature: The NodeSet_Cast function in dql/html, dql/maps, and dql/reflects packages has been updated to use iter.Seq for casting sequences of nodes, aligning with modern Go iteration patterns.
  • Improved HTML Document Node Handling: The Root function in dql/html/html.go now includes logic to automatically skip the document node if it is the sole child, simplifying subsequent node processing.
  • Optimized XML Data Copying: The internal mechanism for copying xml.Attr and xml.CharData in dql/xml/parse.go has been optimized using append([]Type(nil), ...) for potentially better performance and clarity.
  • New and Updated Test Cases: New test cases (cl/_testgop/dql5) have been added for HTML parsing demonstrating the dump method, and an existing XML test case (cl/_testgop/dql4) has been updated to utilize the new _dump functionality.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cl/_testgop/dql4/in.xgo
    • Updated DQL query to use the new _dump method.
  • cl/_testgop/dql4/out.go
    • Modified generated Go code to invoke the XGo_dump method.
  • cl/_testgop/dql5/in.xgo
    • Added a new DQL test file to demonstrate HTML parsing with the dump method.
  • cl/_testgop/dql5/out.go
    • Generated a new Go test file for HTML parsing, including dump functionality.
  • dql/html/html.go
    • Imported fmt and os packages.
    • Updated NodeSet_Cast function signature to accept iter.Seq[*Node].
    • Adjusted Root function to skip the document node if it's the only child.
    • Added a Dump method to the NodeSet type for debugging.
  • dql/html/parse.go
    • Added a Dump method to the File type for debugging.
  • dql/maps/maps.go
    • Updated NodeSet_Cast function signature to accept iter.Seq[Node].
  • dql/reflects/reflects.go
    • Updated NodeSet_Cast function signature to accept iter.Seq[Node].
  • dql/xml/parse.go
    • Optimized copying of xml.Attr and xml.CharData using append([]Type(nil), ...).
    • Added an XGo_dump method to the Node type for debugging.
  • dql/xml/xml.go
    • Imported fmt and os packages.
    • Updated NodeSet_Cast function signature to accept iter.Seq[*Node].
    • Added an XGo_dump method to the NodeSet type for debugging.
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.

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.10%. Comparing base (9f37182) to head (80bdf12).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2625   +/-   ##
=======================================
  Coverage   94.10%   94.10%           
=======================================
  Files          32       32           
  Lines        9949     9949           
=======================================
  Hits         9363     9363           
  Misses        418      418           
  Partials      168      168           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xushiwei xushiwei merged commit b4ef57c into goplus:main Feb 15, 2026
11 checks passed
Copy link
Contributor

@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 dump functions for dql/xml and dql/html to aid in debugging queries. While these methods are useful for development, they hardcode output to os.Stderr, which can lead to sensitive information exposure in production logs. The implementation includes good test cases and refactoring, such as standardizing on iter.Seq for NodeSet_Cast and using a more idiomatic way to copy slices in dql/xml/parse.go, which appear safe. There are also suggestions to make the new dump functions even more informative.

Comment on lines +431 to +446
func (p NodeSet) Dump() NodeSet {
if p.Err == nil {
p.Data(func(node *Node) bool {
switch node.Type {
case html.ElementNode:
fmt.Fprintln(os.Stderr, "==> element:", node.Data, node.Attr)
case html.TextNode:
fmt.Fprintln(os.Stderr, "==> text:", node.Data)
case html.DocumentNode:
fmt.Fprintln(os.Stderr, "==> document")
}
return true
})
}
return p
}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The Dump method hardcodes logging of HTML node data (including tag names, attributes, and text content) directly to os.Stderr. This can lead to the exposure of sensitive information (e.g., PII, session tokens, or secrets) in system logs if the method is used in a production environment. It is recommended to allow the caller to provide an io.Writer or to use a configurable logger instead of hardcoding os.Stderr. Additionally, to make the Dump function even more comprehensive for debugging, consider handling other common node types like html.CommentNode and html.DoctypeNode in the switch statement.

Comment on lines +291 to +299
func (p NodeSet) XGo_dump() NodeSet {
if p.Err == nil {
p.Data(func(node *Node) bool {
fmt.Fprintln(os.Stderr, "node:", node.Name.Local, node.Attr)
return true
})
}
return p
}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The XGo_dump method hardcodes logging of XML node data (including element names and attributes) directly to os.Stderr. This can lead to the exposure of sensitive information in system logs if used in a production environment. It is recommended to allow the caller to provide an io.Writer or to use a configurable logger instead of hardcoding os.Stderr. Additionally, for better debugging, it would be beneficial to also include the node's text content, which can be achieved using the existing Root(node).XGo_text__0() helper.

Comment on lines +69 to +71
func (f *File) Dump() NodeSet {
return Root(&f.Node).Dump()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

This Dump method calls the underlying NodeSet.Dump which hardcodes logging to os.Stderr. This can lead to sensitive information exposure in production logs. Consider providing a way to specify the output stream.

Comment on lines +114 to +116
func (n *Node) XGo_dump() NodeSet {
return Root(n).XGo_dump()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

This XGo_dump method calls the underlying NodeSet.XGo_dump which hardcodes logging to os.Stderr. This can lead to sensitive information exposure in production logs. Consider providing a way to specify the output stream.

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