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

bad tree structure error when creating a child under a family #2707

Closed
grantfitzsimmons opened this issue Dec 23, 2022 · 3 comments · Fixed by #2753
Closed

bad tree structure error when creating a child under a family #2707

grantfitzsimmons opened this issue Dec 23, 2022 · 3 comments · Fixed by #2753
Assignees
Labels
1 - Bug Incorrect behavior of the product

Comments

@grantfitzsimmons
Copy link
Member

grantfitzsimmons commented Dec 23, 2022

  1. Navigate to this section in the tree:

http://localhost/specify/tree/taxon/?conformation=%7E%7E1%7E204425-%7E181107%7E4690%7E7330-%7E5162-%7E7299%7E194257----%7E2%7E10%7E16%7E617------

Notice that "Chaetodermatidae" is selected.

image

  1. Click "Add Child"
  2. Create a child named "grant-test" and assign it the rank of Genus

image

  1. Click "Save" and you will see this error:
AssertionError at /api/specify/taxon/
bad tree structure

See the expanded error below:
Specify 7 Crash Report - 2022-12-23T21_06_26.336Z.txt

Traceback

/opt/specify7/specifyweb/specify/tree_extras.py in validate_node_numbers
from specifyweb.businessrules.exceptions import BusinessRuleException
from  .auditcodes import TREE_MERGE, TREE_SYNONYMIZE, TREE_DESYNONYMIZE
@contextmanager
def validate_node_numbers(table, revalidate_after=True):
    try:
        validate_tree_numbering(table) …
    except AssertionError:
        renumber_tree(table)
    yield
    if revalidate_after:
        validate_tree_numbering(table)

Seems to be similar to the issue here: #2704


db: UMich_mollusks_2022_12_22
On test panel already
Version v7.7.5

Reported By: Matthew Cruz at UMich

@melton-jason
Copy link
Contributor

melton-jason commented Dec 26, 2022

This issue seems to be of the same vein as #2704 (comment) (Specify found instances where some taxa have children that have the same or higher rank).

I ran the following SQL command and got the following results:

select c.taxonid as childid, p.taxonid as parentid, c.fullname as childName, p.fullname as parentName, c.parentid as childParentID, p.parentid as parentParentID, c.acceptedid as childAcceptedID from taxon c join taxon p on c.parentid=p.taxonid where c.rankid <= p.rankid order by c.fullname;
+---------+----------+--------------------------+-------------------------------------+---------------+----------------+-----------------+
| childid | parentid | childName                | parentName                          | childParentID | parentParentID | childAcceptedID |
+---------+----------+--------------------------+-------------------------------------+---------------+----------------+-----------------+
|      88 |      102 | Acanthochitonida         | Acanthochitonina                    |           102 |             84 |             312 |
|   11687 |    11547 | Aequipecten aequisculata | Chlamys circularis                  |         11547 |           2722 |           20987 |
|   19211 |     4924 | Amphitretus thielei      | Amphitretus pelagicus               |          4924 |           3023 |           20807 |
|   13869 |     8514 | Astarte lens             | Astarte crenata                     |          8514 |           3624 |           20119 |
|    9972 |     8514 | Astarte subequilatera    | Astarte crenata                     |          8514 |           3624 |           20119 |
|    5838 |    19217 | Balcis borealis          | Melanella micrans                   |         19217 |           2761 |           21030 |
|   16606 |    16719 | Bathypolypus proschi     | Bathypolypus arcticus               |         16719 |           3079 |           20559 |
|    8663 |    15962 | Buccinum fucanum         | Buccinum strigillatum               |         15962 |           1444 |           20064 |
|    6993 |    19820 | Bulla occidentalis       | Bulla striata                       |         19820 |           1087 |           20625 |
|   19702 |    19820 | Bulla umbilicata         | Bulla striata                       |         19820 |           1087 |           20625 |
|   12759 |    11711 | Busycon muricatum        | Busycon carica                      |         11711 |           3246 |           20531 |
|   13454 |     5909 | Busycon pyrum            | Busycon spiratum                    |          5909 |           3246 |           20429 |
|    9720 |     4057 | Calliteuthis celetaria   | Histioteuthis celetaria             |          4057 |           1758 |           20879 |
|    7664 |    13555 | Calliteuthis corona      | Histioteuthis corona                |         13555 |           1758 |           20784 |
|   15592 |    13555 | Calliteuthis inermis     | Histioteuthis corona                |         13555 |           1758 |           20267 |
|      14 |       10 | Caudofoveata             | Aplacophora                         |            10 |              2 |              16 |
|   12576 |     4237 | Cerithiopsis taeniolata  | Cerithiopsis metaxae                |          4237 |           2754 |           20719 |
|   19797 |    11713 | Cerithium algicola       | Cerithium eburneum                  |         11713 |           3049 |           20911 |
|   15429 |    10112 | Cerithium biminiense     | Cerithium lutosum                   |         10112 |           3049 |           20758 |
|   19903 |    16089 | Chiroteuthis lacertosa   | Chiroteuthis (Chiroteuthis) veranyi |         16089 |           3797 |           21055 |
|   19534 |     3943 | Chlamys costellatus      | Chlamys islandica                   |          3943 |           2722 |           20190 |
|   12600 |     5413 | Clio caudata             | Clio pyramidata                     |          5413 |           2642 |           20494 |
|   10606 |     5413 | Clio exacuta             | Clio pyramidata                     |          5413 |           2642 |           20494 |
|   12488 |     5413 | Clio lata                | Clio pyramidata                     |          5413 |           2642 |           20494 |
|   19686 |     5413 | Clio lobata              | Clio pyramidata                     |          5413 |           2642 |           20494 |
|   18466 |     5413 | Clio occidentalis        | Clio pyramidata                     |          5413 |           2642 |           20494 |
|   11905 |     6777 | Colus marshalli          | Colus jeffreysianus                 |          6777 |           3161 |           20228 |
|    2496 |     2567 | Compsoteuthis            | Abralia                             |          2567 |            717 |            3766 |
|    5577 |    10528 | Conus fosteri            | Conus villepinii                    |         10528 |           1607 |           20257 |
|   17214 |    18807 | Conus pygmaeus           | Conasprella jaspideus               |         18807 |          40145 |           20452 |
|    9906 |    19066 | Cylichnella eximia       | Acteocina culcitella                |         19066 |           2253 |           20378 |
|   17981 |    15964 | Cymatium pacificum       | Neptunea lyrata                     |         15964 |           1890 |           20598 |
|    9047 |    15511 | Eledonella purpurea      | Bolitaena massyae                   |         15511 |           1069 |           20148 |
|   16082 |    11416 | Elimia laqueata laqueata | Elimia laqueata                     |         11416 |           1219 |           20678 |
|    3096 |     2567 | Enigmoteuthis            | Abralia                             |          2567 |            717 |            3775 |
|   16796 |     5044 | Ervilia rostratula       | Ervilia concentrica                 |          5044 |           3634 |           19975 |
|   13459 |    19191 | Fasciolaria distans      | Fasciolaria lilium                  |         19191 |           3359 |           20304 |
|   17781 |    19191 | Fasciolaria hunteria     | Fasciolaria lilium                  |         19191 |           3359 |           21081 |
|    6273 |    14368 | Goniobasis angulata      | Elimia cahawbensis                  |         14368 |           1219 |           20000 |
|    5120 |    13127 | Goniobasis arachnoidea   | Elimia arachnoidea                  |         13127 |           1219 |           20067 |
|    8078 |    19715 | Goniobasis boykiniana    | Elimia boykiniana                   |         19715 |           1219 |           21083 |
|    9602 |    11416 | Goniobasis castanea      | Elimia laqueata                     |         11416 |           1219 |           20085 |
|   14210 |     4205 | Goniobasis comalensis    | Elimia comalensis                   |          4205 |           1219 |           20511 |
|   17830 |    16136 | Goniobasis crandalli     | Elimia potosiensis                  |         16136 |           1219 |           20984 |
|    5447 |     6299 | Goniobasis ebenum        | Elimia ebenum                       |          6299 |           1219 |           20682 |
|   18740 |     6299 | Goniobasis emeryensis    | Elimia ebenum                       |          6299 |           1219 |           20938 |
|    3984 |    17726 | Goniobasis georgiana     | Elimia lecontiana                   |         17726 |           1219 |           21054 |
|    4214 |     5682 | Goniobasis gracilior     | Elimia livescens                    |          5682 |           1219 |           19921 |
|   16734 |     5682 | Goniobasis haldemani     | Elimia livescens                    |          5682 |           1219 |           20774 |
|   10778 |     5682 | Goniobasis livescens     | Elimia livescens                    |          5682 |           1219 |           21037 |
|    7975 |    19300 | Goniobasis mutabilis     | Elimia mutabilis                    |         19300 |           1219 |           20597 |
|    5168 |    16136 | Goniobasis ozarkensis    | Elimia potosiensis                  |         16136 |           1219 |           19987 |
|    4507 |     6647 | Goniobasis perstriata    | Elimia perstriata                   |          6647 |           1219 |           20995 |
|   10960 |    16136 | Goniobasis plebeius      | Elimia potosiensis                  |         16136 |           1219 |           20433 |
|    8900 |    13127 | Goniobasis spinella      | Elimia arachnoidea                  |         13127 |           1219 |           20885 |
|    8107 |    19715 | Goniobasis viennaensis   | Elimia boykiniana                   |         19715 |           1219 |           20488 |
|    9406 |    17013 | Lacuna glacialis         | Lacuna crassior                     |         17013 |           2344 |           20094 |
|   17371 |    12831 | Lampsilis claibornensis  | Lampsilis straminea                 |         12831 |           1639 |           20585 |
|   10050 |     8708 | Latirus macgintyi        | Latirus carinifer                   |          8708 |           2038 |           20653 |
|   13816 |    16089 | Leptoteuthis diaphana    | Chiroteuthis (Chiroteuthis) veranyi |         16089 |           3797 |           21055 |
|    5913 |    17338 | Littorina arctica        | Littorina obtusata                  |         17338 |           1041 |           20767 |
|    5188 |    19327 | Littorina groenlandica   | Littorina saxatilis                 |         19327 |           1041 |           20814 |
|    9334 |    17338 | Littorina palliata       | Littorina obtusata                  |         17338 |           1041 |           20077 |
|    7568 |    19327 | Littorina rudis          | Littorina saxatilis                 |         19327 |           1041 |           20092 |
|   13254 |    19327 | Littorina tenebrosus     | Littorina saxatilis                 |         19327 |           1041 |           20612 |
|    4625 |    10999 | Loligo reynaudii         | Loligo (Loligo) vulgaris            |         10999 |           3772 |           21064 |
|   15871 |    16089 | Loligopsis veranii       | Chiroteuthis (Chiroteuthis) veranyi |         16089 |           3797 |           20114 |
|    3011 |     2822 | Megastropha              | Helisoma                            |          2822 |            202 |            3791 |
|    3608 |     3601 | Micromenetus             | Menetus                             |          3601 |            202 |            3779 |
|   19866 |    15018 | Neptunea borealis        | Neptunea communis                   |         15018 |           1890 |           20031 |
|   19698 |    15964 | Neptunea obsoleta        | Neptunea lyrata                     |         15964 |           1890 |           20598 |
|    8666 |    15964 | Neptunea pacificum       | Neptunea lyrata                     |         15964 |           1890 |           20598 |
|   16246 |    15964 | Neptunea phoenicia       | Neptunea lyrata                     |         15964 |           1890 |           20598 |
|   15207 |     9239 | Ommatostrephes pacificus | Todarodes pacificus                 |          9239 |           3225 |           20677 |
|   16204 |     9660 | Petaloconchus nigricans  | Petaloconchus varians               |          9660 |           3486 |           19996 |
|    4361 |    10799 | Polypus tenuipulvinus    | Octopus minor                       |         10799 |           2544 |           20062 |
|   13313 |    16140 | Pomacea orinocoensis     | Pomacea glauca                      |         16140 |           1030 |           20601 |
|    4347 |     4126 | Retusa turrita           | Retusa obtusa                       |          4126 |           2346 |           20990 |
|    8574 |    10517 | Simnia vidleri           | Simnia aequalis                     |         10517 |           3348 |           21028 |
|       8 |       10 | Solenogastres            | Aplacophora                         |            10 |              2 |              16 |
|   11353 |     6496 | Spisula alaskana         | Mactromeris polynyma                |          6496 |           2691 |           20765 |
|    7161 |    15932 | Teinostoma invallatum    | Teinostoma supravallatum            |         15932 |           1813 |           19931 |
|    5885 |    16339 | Trophon catalinensis     | Trophon cerrosensis                 |         16339 |           3734 |           20089 |
|   19185 |    10807 | Turbo crenulatus         | Turbo castanea                      |         10807 |           2665 |           20800 |
|    4914 |    15785 | Venus striatula          | Venus gallina                       |         15785 |           2007 |           20952 |
+---------+----------+--------------------------+-------------------------------------+---------------+----------------+-----------------+

@maxpatiiuk
should this Assertion Error be thrown even if the children nodes are synonymized? Was this intended?

The error is thrown here (note this is on the 7.7.5 tag):

# make sure there are no cycles
cursor.execute((
"select count(*) from {table} t\n"
"join {table} p on t.parentid = p.{table}id\n"
"where t.rankid <= p.rankid\n"
).format(table=table))
assert (0, ) == cursor.fetchone(), "bad tree structure"

@grantfitzsimmons
Copy link
Member Author

grantfitzsimmons commented Dec 27, 2022

Screen.Recording.2022-12-27.at.6.15.52.AM.mov

Still an issue on 7.7.0, 7.7.4, 7.7.5, and 7.8.1.

/opt/specify7/specifyweb/specify/tree_extras.py in validate_node_numbers
from specifyweb.businessrules.exceptions import BusinessRuleException
from  .auditcodes import TREE_MERGE, TREE_SYNONYMIZE, TREE_DESYNONYMIZE
@contextmanager
def validate_node_numbers(table, revalidate_after=True):
    try:
        validate_tree_numbering(table) …
    except AssertionError:
        renumber_tree(table)
    yield
    if revalidate_after:
        validate_tree_numbering(table)

Same major error:

AssertionError at /api/specify/taxon/
bad tree structure

Video is version v7.7.4

melton-jason added a commit that referenced this issue Jan 10, 2023
Additionally, provide more data to allow users to diagnose
'bad tree structure' errors so issues like #2704 and #2707
have more context and don't have to run SQL commands to find
the bad nodes.
@melton-jason melton-jason added this to the 7.8.4 (internal bugs) milestone Jan 12, 2023
@specifysoftware
Copy link

This issue has been mentioned on Specify Community Forum. There might be relevant details there:

https://discourse.specifysoftware.org/t/specify-7-8-4-announcement/999/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Bug Incorrect behavior of the product
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants