Skip to content

friendlier error for DOIs without citation metadata#1061

Open
kevinushey wants to merge 3 commits into
quarto-dev:mainfrom
kevinushey:bugfix/doi-csl-error-message
Open

friendlier error for DOIs without citation metadata#1061
kevinushey wants to merge 3 commits into
quarto-dev:mainfrom
kevinushey:bugfix/doi-csl-error-message

Conversation

@kevinushey

@kevinushey kevinushey commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

When inserting a citation from a DOI, the lookup uses DOI content negotiation (an Accept: application/vnd.citationstyles.csl+json header against https://doi.org/<doi>). For DOIs whose registration agency does not support content negotiation (e.g. 10.1000/182, the DOI Handbook itself), the request just redirects to the HTML landing page, and the editor surfaced a raw JSON parse error:

invalid json response body at https://www.doi.org/the-identifier/resources/handbook/ reason: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

This PR detects the "resolved, but not to JSON" case and reports a human-readable message instead:

This DOI was found, but no citation data is available for it. This usually means the organization that registered the DOI does not support automatic citation lookup. To cite this work, you can add an entry to your bibliography manually.

Noticed while reviewing #1060 (#1060 (review)).

Verified manually by calling doiServer().fetchCSL() directly: 10.1000/182 now returns the friendly error, and a real Crossref DOI (10.1038/nature12373) still returns CSL metadata.

@posit-snyk-bot

posit-snyk-bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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