Turn an XPath Lookup Bug into a Reproducible Debugging Walkthrough

1 comment

Apps it uses

I turned an open-source XML lookup fix into a debugging walkthrough that other developers can run. I used Codex, Python, and GitHub to document a bug where a document style containing quotation marks could be saved but then fail during retrieval because its name was interpolated into an XPath expression.

Step-by-step

  1. I gave Codex the original patch and inspected the affected code, tracing the stored value through the public API, the wrapper, and the XML library.
  2. I extracted the smallest standalone reproduction with `lxml`. It included a name containing both single and double quotes and kept the failing lookup visible.
  3. I replaced interpolation with a bound variable: `styles.xpath("style[@name=$name]", name=name)`. I checked that the wrapper forwarded variables while preserving its namespace mapping.
  4. I ran both versions. The interpolated version raised `XPathEvalError` in my reproduction. Binding the value matched five exact names, while an absent name returned no match.
  5. I published the explanation, executable example, and upstream patch together. I inspected the rendered article and links and disclosed AI assistance.

A prompt to reuse: "Reduce this lookup failure to a runnable example. Keep the failing case, show the fix, and check ordinary text, both quote types, custom namespaces and a missing value. Report which checks actually ran."

The original fix had already been merged, so this workflow documents it. Broader service behavior needs separate tests. I used my existing Codex and local Python setup and did not measure time savings.

I am Hồ Khắc Huy, a freelance software engineer. This is my independent open-source work. The linked article includes the runnable example, upstream contribution, and my contact details: https://github.com/builtbyhuy/builtbyhuy/blob/main/notes/2026-09-06-xpath-variables.md

1 comment

Have a question about this workflow, or a way to improve it?

Log in to comment Create a free account
Brooke Benson Pro The Rundown team

was Codex good at following the value through all the wrapper layers or did you have to hold its hand?

Posting guidelines