Skip to content

Detect the MultiXML constant to avoid the multi_xml deprecation#2765

Merged
dblock merged 2 commits into
masterfrom
fix/multixml-deprecation
Jun 14, 2026
Merged

Detect the MultiXML constant to avoid the multi_xml deprecation#2765
dblock merged 2 commits into
masterfrom
fix/multixml-deprecation

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

Background

multi_xml 0.9.0 renamed its constant from MultiXml to MultiXML (same modernization as multi_json 1.21.0, by the same author). MultiXml is now a deprecated alias, removed in v1.0, that emits a one-time warning on constant access or method call:

The MultiXml constant is deprecated and will be removed in v1.0. Use MultiXML instead.

lib/grape/xml.rb detected the backend via ::MultiXml and Grape::Xml.parse resolved to MultiXml.parse, so users on multi_xml >= 0.9 would hit the deprecation.

What this PR does

Detect ::MultiXML first, then fall back to the legacy ::MultiXml constant, then ActiveSupport::XmlMini:

Backend Grape::Xml
multi_xml >= 0.9 ::MultiXML
multi_xml < 0.9 ::MultiXml
no multi_xml ::ActiveSupport::XmlMini

Unlike the multi_json counterpart (#2764), no facade is needed. multi_xml's only method-level deprecation is loadparse, and Grape calls only parse, which is canonical (not renamed) on every backend — so a direct constant alias suffices.

CI covers both multi_xml lines

gemfiles/multi_xml.gemfile is pinned to >= 0.9 and a new gemfiles/multi_xml_0_8.gemfile pins < 0.9; both run the spec/integration/multi_xml suite, exercising the MultiXML and legacy-MultiXml paths. The integration spec now drives a real Grape API that parses an XML request body through Grape::Xml.parse (rather than a static constant-equality check), so a regression onto the deprecated constant surfaces via the suite's deprecation handler.

Testing

  • BUNDLE_GEMFILE=gemfiles/multi_xml.gemfile bundle exec rspec spec/integration/multi_xml (>= 0.9, resolves to 0.9.1): 1 example, 0 failures
  • BUNDLE_GEMFILE=gemfiles/multi_xml_0_8.gemfile bundle exec rspec spec/integration/multi_xml (< 0.9, resolves to 0.8.1): 1 example, 0 failures
  • bundle exec rspec (no multi_xml, XmlMini fallback): 2322 examples, 0 failures
  • Verified the integration spec fails against the pre-fix lib/grape/xml.rb under multi_xml 0.9.1 (the deprecation surfaces), confirming it guards the regression.
  • RuboCop clean.

This is the multi_xml counterpart to #2764 (multi_json).

🤖 Generated with Claude Code

@ericproulx ericproulx force-pushed the fix/multixml-deprecation branch from 35108ef to 859d5cb Compare June 14, 2026 11:06
@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@ericproulx ericproulx requested a review from dblock June 14, 2026 11:07
@ericproulx ericproulx force-pushed the fix/multixml-deprecation branch from 859d5cb to 6025bf4 Compare June 14, 2026 11:11
multi_xml 0.9.0 deprecated the `MultiXml` constant in favor of `MultiXML`
(removed in v1.0); the legacy constant warns on access/use. Grape detected
the backend via `::MultiXml` and called `Grape::Xml.parse`, so users on
multi_xml >= 0.9 would hit the deprecation.

Detect `::MultiXML` first, falling back to the legacy `::MultiXml` constant
and then `ActiveSupport::XmlMini`. Unlike multi_json, no facade is needed:
`parse` is canonical (not renamed) and Grape only calls `parse`, so a direct
alias suffices on every backend.

Cover both multi_xml lines in CI: pin gemfiles/multi_xml.gemfile to >= 0.9
and add gemfiles/multi_xml_0_8.gemfile (< 0.9), each running the
spec/integration/multi_xml suite. The integration spec now drives a real
Grape API that parses an XML request body through Grape::Xml.parse.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ericproulx ericproulx force-pushed the fix/multixml-deprecation branch from 6025bf4 to bbfc83a Compare June 14, 2026 11:12
@ericproulx

Copy link
Copy Markdown
Contributor Author

@dblock I'm gonna cut a version after this one.

@dblock dblock merged commit 0e23f01 into master Jun 14, 2026
69 checks passed
@dblock dblock deleted the fix/multixml-deprecation branch June 14, 2026 16:00
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.

2 participants