Support RDF/XML and Turtle content negotiation; fix wildcard Accept 500#1518
Open
Support RDF/XML and Turtle content negotiation; fix wildcard Accept 500#1518
Conversation
…ct for HTML fallback Agent-Logs-Url: https://github.com/datacite/lupo/sessions/78ba3e36-39d3-454a-89b1-792566149549 Co-authored-by: ashwinisukale <1137325+ashwinisukale@users.noreply.github.com>
Agent-Logs-Url: https://github.com/datacite/lupo/sessions/78ba3e36-39d3-454a-89b1-792566149549 Co-authored-by: ashwinisukale <1137325+ashwinisukale@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix RDF/XML and Turtle content negotiation issues
Support RDF/XML and Turtle content negotiation; fix wildcard Accept 500
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accept: */*and no-Accept requests were returning 500 due to Rails unsafe-redirect protection blocking cross-host redirects in theformat.htmlbranch. Additionally,application/rdf+xmlandtext/turtlewere not supported as representations — both redirected 303 instead of returning content.Changes
Unsafe redirect fix (
app/controllers/index_controller.rb)allow_other_host: truetoformat.htmlredirect — matches the already-correct rescue branch; eliminates 500 for wildcard/no-Accept requestsRDF/XML + Turtle MIME registration (
config/initializers/mime_types.rb)application/rdf+xml→:rdf_xmltext/turtle→:turtle(withapplication/x-turtleas alias)obj.rdf_xml/obj.turtlefrom Bolognese'sRdfXmlWriter/TurtleWriter, already included inDoiviaCrosscitable— no network calls, no new dependenciesController wiring (
app/controllers/index_controller.rb):rdf_xmland:turtleto theformat.any(...)blockLink-form routes (
config/routes.rb)Request specs (
spec/requests/index_spec.rb)application/rdf+xml,text/turtle,application/x-turtleAccept: */*guard (must not return 500)Original prompt
Create a PR in
datacite/lupoto fully support RDF/XML and Turtle content negotiation (both header-based and link-form routes) without making network calls, and fix wildcard/no-Accept redirect failures.Context / current behavior (stage testing):
Accept: */*and requests with noAcceptheader currently return 500 due to Rails unsafe redirect protection when redirecting todoi.url.Accept: application/rdf+xmlandAccept: text/turtlecurrently redirect (303) instead of returning RDF.Requirements:
Fix unsafe redirect for HTML fallback in
app/controllers/index_controller.rb:format.htmlbranch ofIndexController#show, redirect todoi.urlmust includeallow_other_host: true(to avoid 500).:see_other.Add RDF/XML + Turtle response support in Lupo (no network calls):
application/rdf+xml(format symbol:rdf_xml).text/turtleand legacyapplication/x-turtle(format symbol:turtle).GET /:doiwithAccept:) and link-form routes (GET /application/rdf+xml/:id,GET /application/x-turtle/:id,GET /text/turtle/:id).No network calls:
Implementation approach guidance:
Update MIME types and renderers:
config/initializers/mime_types.rbregisters:application/rdf+xml=>:rdf_xmlapplication/x-turtle=>:turtletext/turtle=>:turtle:rdf_xmland:turtle.Update
IndexController#show::rdf_xmland:turtlein theformat.any(...)block that rendersrender request.format.to_sym => doi.Add routes for link-form content negotiation:
config/routes.rb, add GET routes mapping toIndexController#showwith defaults:/application/rdf+xml/:id=> format:rdf_xml/application/x-turtle/:id=> format:turtle/text/turtle/:id=> format:turtleconstraints: { id: /.+/ }consistent with other CN routes.Tests:
GET /:doiwithAccept: application/rdf+xmlreturns 200 and Content-Type containsapplication/rdf+xml.GET /:doiwithAccept: application/x-turtlereturns 200 and Content-Type containsapplication/x-turtleORtext/turtle(depending on mime registration) and body contains Turtle-like content (e.g.,@prefix schema:).GET /:doiwithAccept: text/turtlereturns 200 and turtle body./application/rdf+xml/:doi/application/x-turtle/:doi/text/turtle/:doiGET /:doiwithAccept: */*does not 500 and redirects (302/303) todoi.url.GET /:doiwith noAcceptheader does not 500 and redirects.PR description requirements:
Notes:
http://datacite.org/) to exercise redirect behavior.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Running Lupo Content Negotiation Compliance Tests
Base: https://api.stage.datacite.org
======================================
Testing DOI: 10.81360/BIFURCATED
Base: https://api.stage.datacite.org
Require link routes: 0
✅ PASS: DataCite XML (header) (status=200)
✅ PASS: DataCite XML CT (header) (ct=application/vnd.datacite.datacite+xml; charset=utf-8)
✅ PASS: DataCite XML (link) supported
✅ PASS: DataCite JSON (header) (status=200)
✅ PASS: DataCite JSON CT (header) (ct=application/vnd.datacite.datacite+json; charset=utf-8)
✅ PASS: DataCite JSON (link) supported
✅ PASS: JSON-LD (header) (status=200)
✅ PASS: JSON-LD CT (header) (ct=application/vnd.schemaorg.ld+json; charset=utf-8)
✅ PASS: JSON-LD (link) supported
✅ PASS: CSL JSON (header) (status=200)
✅ PASS: CSL JSON CT (header) (ct=application/vnd.citationstyles.csl+json; charset=utf-8)
✅ PASS: CSL JSON (link) supported
✅ PASS: Codemeta (header) (status=200)
✅ PASS: Codemeta CT (header)...
This pull request was created from Copilot chat.