Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Adding a reference via URL for the second time fails #2067

Open
nsunami opened this issue May 16, 2024 · 2 comments
Open

🐛 Adding a reference via URL for the second time fails #2067

nsunami opened this issue May 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working Stale

Comments

@nsunami
Copy link
Collaborator

nsunami commented May 16, 2024

URL of the Page

/drafts

What happened?

As reported in #1991, we cannot add some DOIs formatted as a URL (e.g., https://doi.org/10.1007/978-3-031-17037-9_4)

I took a look, and it seems like it only happens when I try to add the item for the second time.

So for the first time, the app fetches data and creates a new DB item without a problem.

But for the second time when I enter the DOI-URL, the app again tries to fetch & add again, resulting in a failed constraint as below:

[blitz-rpc]     createReferenceModule() Starting with input: {
  doi: '10.1007/978-3-031-17037-9_4'
}
Error: 
Invalid `prisma.module.create()` invocation:


Unique constraint failed on the fields: (`prefix`,`suffix`)

I will try fixing this problem by making sure that the workflow to add an existing module proceeds when the URL-DOI is inputted for an existing module.

Steps to reproduce

  1. Create a draft module
  2. Add the following DOI-URL as a reference: https://doi.org/10.1007/978-3-031-17037-9_4
  3. Delete the reference
  4. Try adding the above DOI-URL again

image

What browser(s) did you use?

Chrome

Anything else?

No response

@nsunami nsunami added the bug Something isn't working label May 16, 2024
@nsunami nsunami assigned chartgerink and nsunami and unassigned chartgerink May 16, 2024
@nsunami
Copy link
Collaborator Author

nsunami commented Jun 24, 2024

I've been working on the ModuleEdit file. I noticed that the DOI with a URL will go to Algolia, but then the DOI with a URL will not produce a hit on the Algolia side, thus going into the routine for not-found.

I'm thinking of cleaning the query string before sending out to Algolia. I see that the current match is handeled with below code:

matchedQuery
? matchedQuery.slice(-1)[0].endsWith("/")
? matchedQuery.slice(-1)[0].slice(0, -1)
: matchedQuery.slice(-1)[0]

Investigating whether this can be replaced with something below:

const matchedQuery = query.match(/10.\d{4,9}\/[-._;()\/:A-Z0-9]+$/i)
const matchedDoi = matchedQuery && matchedQuery[0]

Copy link

This issue is stale because it has been open 60 days with no activity.

@github-actions github-actions bot added the Stale label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants