Skip to content

Fix CI: add missing data.xml dependency and fix duplicate XML declaration - #1

Merged
tooooolong merged 2 commits into
mainfrom
claude/fix-ci-pipeline-p7Xt4
Apr 3, 2026
Merged

tooooolong merged 2 commits into
mainfrom
claude/fix-ci-pipeline-p7Xt4

Conversation

@tooooolong

@tooooolong tooooolong commented Apr 3, 2026

Copy link
Copy Markdown
Owner

The cobertura reporter requires clojure.data.xml but it was not declared
as a dependency in project.clj or deps.edn, causing runtime failures.

Also fix xml/emit usage: the :xml-declaration false option is not supported
by data.xml, so emit was producing a duplicate XML declaration making the
output invalid. Switch to emit-str and strip the declaration manually.

https://claude.ai/code/session_01WpM3eidMhXdmEvo9DRX1vH

Summary by CodeRabbit

  • Chores

    • Added the org.clojure/data.xml library dependency (version 0.2.0-alpha10) to project dependencies; no public API changes.
  • Refactor

    • Improved Cobertura XML report generation to stream output and let the XML emitter handle prolog/DOCTYPE placement, yielding cleaner, more consistent report files and more robust resource handling.

@coderabbitai

coderabbitai Bot commented Apr 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cf910e59-0aa6-4a37-8c54-7b7d8e9f642c

📥 Commits

Reviewing files that changed from the base of the PR and between 5ffe239 and 48218f1.

📒 Files selected for processing (3)
  • deps.edn
  • project.clj
  • src/cloverage/coverage/cobertura.clj
✅ Files skipped from review due to trivial changes (2)
  • project.clj
  • deps.edn
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cloverage/coverage/cobertura.clj

📝 Walkthrough

Walkthrough

The PR adds org.clojure/data.xml v0.2.0-alpha10 to build files and modifies the Cobertura XML writer to stream output via io/writer and pass a :doctype option to xml/emit instead of manually writing the XML prolog/DOCTYPE.

Changes

Cohort / File(s) Summary
Dependency files
deps.edn, project.clj
Added org.clojure/data.xml 0.2.0-alpha10; adjusted deps.edn deps formatting to include the new entry.
Cobertura XML Report Writer
src/cloverage/coverage/cobertura.clj
Replaced manual XML prolog/DOCTYPE construction and spit with streaming to a writer via with-open/io/writer; pass :doctype to xml/emit and let emitter produce prolog/DOCTYPE.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through deps and XML light,
Gave data.xml a cozy bite.
Emit now sings the DOCTYPE tune,
Streams the file beneath the moon.
Code nibbles neat—reports take flight.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both primary changes: adding the missing data.xml dependency and fixing the duplicate XML declaration issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-ci-pipeline-p7Xt4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tooooolong
tooooolong requested a review from Copilot April 3, 2026 06:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9500fcdac8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cloverage/coverage/cobertura.clj Outdated
Comment on lines +156 to +157
(let [xml-body (-> (xml/emit-str (xml/sexp-as-element coverage-sexp))
(str/replace-first #"^<\?xml[^?]*\?>\s*" ""))]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid buffering entire report in memory

Switching from xml/emit to xml/emit-str turns XML generation from a streaming write into full in-memory materialization of the Cobertura report. For large codebases, this can significantly increase heap usage in CI and may cause OOMs where the previous implementation would succeed, because the whole document must fit in memory before any bytes are written.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed — switched to streaming xml/emit with the :doctype keyword arg (supported in data.xml 0.2.0-alpha10). No more in-memory buffering; XML streams directly to the file writer.


Generated by Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/cloverage/coverage/cobertura.clj (1)

151-158: Workaround approach is sound, but regex could be slightly more robust.

The manual prolog + strip approach correctly addresses the duplicate XML declaration issue. The regex #"^<\?xml[^?]*\?>\s*" works for typical output but may fail if the declaration contains a ? in an encoding name (unlikely but possible). A more defensive pattern:

(str/replace-first #"^<\?xml[^>]*\?>\s*" "")

However, since emit-str produces predictable output (<?xml version="1.0" encoding="UTF-8"?>), the current regex is acceptable in practice.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cloverage/coverage/cobertura.clj` around lines 151 - 158, The regex used
to strip the XML declaration when writing the coverage output in the block that
calls xml/emit-str and xml/sexp-as-element is slightly brittle (it uses
str/replace-first with #"^<\?xml[^?]*\?>\s*"); update that replacement to use a
more robust pattern such as matching up to the closing '>' (e.g.,
#"^<\?xml[^>]*\?>\s*") so the declaration is always removed reliably before
writing xml-body to writer; keep the surrounding logic (manual prolog,
coverage-sexp, xml-body, writer writes) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@project.clj`:
- Line 7: The project declares dependency org.clojure/data.xml "0.2.0-alpha9"
which is outdated; update that dependency version in project.clj to either
"0.2.0-alpha10" if you need the newer XML namespace and ClojureScript support,
or to the stable "0.0.8" if you prefer a non-alpha release—edit the
org.clojure/data.xml entry accordingly so the project uses the chosen version.

---

Nitpick comments:
In `@src/cloverage/coverage/cobertura.clj`:
- Around line 151-158: The regex used to strip the XML declaration when writing
the coverage output in the block that calls xml/emit-str and xml/sexp-as-element
is slightly brittle (it uses str/replace-first with #"^<\?xml[^?]*\?>\s*");
update that replacement to use a more robust pattern such as matching up to the
closing '>' (e.g., #"^<\?xml[^>]*\?>\s*") so the declaration is always removed
reliably before writing xml-body to writer; keep the surrounding logic (manual
prolog, coverage-sexp, xml-body, writer writes) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e9a0197-0247-4d75-a9b0-79ee241daa58

📥 Commits

Reviewing files that changed from the base of the PR and between 54fea3e and 9500fcd.

📒 Files selected for processing (3)
  • deps.edn
  • project.clj
  • src/cloverage/coverage/cobertura.clj

Comment thread project.clj Outdated
@tooooolong

Copy link
Copy Markdown
Owner Author

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/cloverage/coverage/cobertura.clj (1)

151-158: Workaround approach is sound, but regex could be slightly more robust.

The manual prolog + strip approach correctly addresses the duplicate XML declaration issue. The regex #"^<\?xml[^?]*\?>\s*" works for typical output but may fail if the declaration contains a ? in an encoding name (unlikely but possible). A more defensive pattern:

(str/replace-first #"^<\?xml[^>]*\?>\s*" "")

However, since emit-str produces predictable output (<?xml version="1.0" encoding="UTF-8"?>), the current regex is acceptable in practice.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cloverage/coverage/cobertura.clj` around lines 151 - 158, The regex used
to strip the XML declaration when writing the coverage output in the block that
calls xml/emit-str and xml/sexp-as-element is slightly brittle (it uses
str/replace-first with #"^<\?xml[^?]*\?>\s*"); update that replacement to use a
more robust pattern such as matching up to the closing '>' (e.g.,
#"^<\?xml[^>]*\?>\s*") so the declaration is always removed reliably before
writing xml-body to writer; keep the surrounding logic (manual prolog,
coverage-sexp, xml-body, writer writes) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@project.clj`:
- Line 7: The project declares dependency org.clojure/data.xml "0.2.0-alpha9"
which is outdated; update that dependency version in project.clj to either
"0.2.0-alpha10" if you need the newer XML namespace and ClojureScript support,
or to the stable "0.0.8" if you prefer a non-alpha release—edit the
org.clojure/data.xml entry accordingly so the project uses the chosen version.

---

Nitpick comments:
In `@src/cloverage/coverage/cobertura.clj`:
- Around line 151-158: The regex used to strip the XML declaration when writing
the coverage output in the block that calls xml/emit-str and xml/sexp-as-element
is slightly brittle (it uses str/replace-first with #"^<\?xml[^?]*\?>\s*");
update that replacement to use a more robust pattern such as matching up to the
closing '>' (e.g., #"^<\?xml[^>]*\?>\s*") so the declaration is always removed
reliably before writing xml-body to writer; keep the surrounding logic (manual
prolog, coverage-sexp, xml-body, writer writes) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e9a0197-0247-4d75-a9b0-79ee241daa58

📥 Commits

Reviewing files that changed from the base of the PR and between 54fea3e and 9500fcd.

📒 Files selected for processing (3)
  • deps.edn
  • project.clj
  • src/cloverage/coverage/cobertura.clj

@codex fix

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes Cobertura report generation failures in CI by adding the missing clojure.data.xml dependency and adjusting Cobertura XML output generation to avoid an invalid duplicate XML declaration.

Changes:

  • Add org.clojure/data.xml to both project.clj and deps.edn.
  • Update Cobertura report writer to generate XML via emit-str and strip the auto-emitted XML declaration to prevent duplicate declarations.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
src/cloverage/coverage/cobertura.clj Adjusts XML emission to avoid duplicate XML declarations in Cobertura output.
project.clj Adds the missing org.clojure/data.xml dependency for Leiningen builds.
deps.edn Adds the missing org.clojure/data.xml dependency for tools.deps builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

claude added 2 commits April 3, 2026 07:45
…tion

The cobertura reporter requires clojure.data.xml but it was not declared
as a dependency in project.clj or deps.edn, causing runtime failures.

Also fix xml/emit usage: the :xml-declaration false option is not supported
by data.xml, so emit was producing a duplicate XML declaration making the
output invalid. Switch to emit-str and strip the declaration manually.

https://claude.ai/code/session_01WpM3eidMhXdmEvo9DRX1vH
…ta.xml

- Use xml/emit with :doctype option instead of emit-str, keeping XML
  generation streaming rather than buffering the entire report in memory
  (addresses Codex P2 review comment)
- Upgrade org.clojure/data.xml from 0.2.0-alpha9 to 0.2.0-alpha10
  (addresses CodeRabbit review comment)

https://claude.ai/code/session_01WpM3eidMhXdmEvo9DRX1vH
@tooooolong
tooooolong force-pushed the claude/fix-ci-pipeline-p7Xt4 branch from 5ffe239 to 48218f1 Compare April 3, 2026 07:45
@tooooolong
tooooolong merged commit 0b4ff06 into main Apr 3, 2026
19 checks passed
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.

3 participants