Skip to content

Fix CollectionObject business rule crash on missing CollectionObjectType#7905

Open
acwhite211 wants to merge 4 commits intomainfrom
issue-7870
Open

Fix CollectionObject business rule crash on missing CollectionObjectType#7905
acwhite211 wants to merge 4 commits intomainfrom
issue-7870

Conversation

@acwhite211
Copy link
Copy Markdown
Member

@acwhite211 acwhite211 commented Apr 7, 2026

Fixes #7870

Saving a CollectionObject with a missing collectionObjectType could trigger a front-end business rule crash and leave the record stuck on the "Loading..." dialog instead of completing the save. This affected older records, including records created in Specify 6, where CollectionObjectTypeID may still be null.

Added a null guard in the CollectionObject collectionObjectType business rule and skip determination taxon tree validation when no collection object type is set. Clear any existing determination taxon save blockers when collectionObjectType is missing. Also added unit tests for saving when collectionObjectType is null and clearing invalid determination blockers when collectionObjectType becomes null

On the back-end, I decided to go ahead and opportunistically normalize legacy null collectionObjectType values when an existing CollectionObject is saved in Specify 7. If the collection already has a default Collection Object Type, that value is applied on save. If both the record and the collection default are null, Specify creates or reuses the collection’s discipline-based default type, assigns it to the collection, and uses it for the saved record. I'm ok with reverting this section if anyone thinks we should leave them as null.

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests

Testing instructions

  • Open a database that contains at least one CollectionObject with no Collection Object Type set (CollectionObjectTypeID = null). Older Specify 6-created records are the main target.
  • Use the CO QB to find a CO record without a COT. If you can't find one, might need to go into the database to set one of them to null. Might be able to set a COT to null in batch edit.
image
  • In Data Entry, open one of those records and confirm the Collection Object Type field is blank.
  • Add a new Determination to the record.
  • Click Save.
  • Verify the save completes normally instead of hanging on the "Loading..." dialog.
  • Verify the page remains usable after save and no infinite loading state appears.
  • Refresh or reopen the record and confirm the new determination was actually saved.
  • Run the same CO QB query to make sure that the COT is not null anymore.
image

@acwhite211 acwhite211 changed the title Fix CollectionObject business rule crash on missing collectionObjectType Fix CollectionObject business rule crash on missing CollectionObjectType Apr 8, 2026
@acwhite211 acwhite211 marked this pull request as ready for review April 8, 2026 19:18
@acwhite211 acwhite211 requested review from a team and grantfitzsimmons April 8, 2026 19:18
Copy link
Copy Markdown
Collaborator

@bhumikaguptaa bhumikaguptaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Verify the save completes normally instead of hanging on the "Loading..." dialog.
  • Verify the page remains usable after save and no infinite loading state appears.
  • Refresh or reopen the record and confirm the new determination was actually saved.
  • Run the same CO QB query to make sure that the COT is not null anymore.

Everything looks good, except when i refresh the page and rerun the query, the COT is still null.
Db:https://kuentoissue7870-issue-7870.test.specifysystems.org/specify/query/new/collectionobject/

@github-project-automation github-project-automation bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

Saving a record without a COT set will result in hanging rather than save

2 participants