openlibhums / openlibhums/janeway

Preprints author search error when multiple users have orcid=""

Open
#3,752 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug dev-ready Priority high Repositories Size L
Dominant language
Python
Stars
239
Forks
97
Avg merge
9d 1h
Merged PRs (30d)
8

Description

Describe the bug
A user clicking "search" without entering text on the add authors step of submitting a preprint produces an error: Account.MultipleObjectsReturned -- get() returned more than one Account -- it returned 2!

This only happens when there are 2 or more accounts where orcid = "" (rather than None)

Alainna believes that both of the accounts in this situation were added through the janeway interface: 1 during submission and 1 through registration.

Janeway version
1.5.0

To Reproduce

  1. Add two users with orcid = ""
  2. Start a preprint submission, click through to add author step
  3. Don't enter any text in the search box
  4. Click "search"

Expected behavior
Both or neither accounts should be returned. No error. :D

For the account model:

  • we should ensure ORCIDs are unique to avoid MultipleObjectsReturned.
  • Write a migration to handle potential duplicates with the following requirements:
    • If a dupe is found, make sure orcid is copied to any linked FrozenAuthor records before wiping the dupe
    • If a duplicate is found where an account has never logged in, it is safe remove the orcid value from it
    • If a duplicate is found where all accounts have logged in, wipe the orcid from all but the latest to have authenticated.
  • The orcid field on the model should not be set as null=True.
    For the frozen author Models across site types:
  • The orcid field on the model should not be set as null=True.

Finally, we should tweak the search so that we don't call get(orcid="") with a blank string

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the preprint submission add-author search described in the report, then inspect the Account model and the FrozenAuthor models across site types. Review the migration requirements for duplicate blank ORCIDs and the blank-string search path; done means duplicate data is handled safely, model nullability is corrected, and searching without text no longer raises MultipleObjectsReturned.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.