nofusscomputing / centurion_erp

An ERP with a focus on ITSM and Automation
MIT License
0 stars 0 forks source link

Ticket linking of items allows items that do not exist #336

Open jasonpagetas opened 1 month ago

jasonpagetas commented 1 month ago

When linking an item to a ticket I accidentally selected services instead of software, I entered the id of the software I wanted in this case 16.

Now in the linked items it shows $service-16

This should throw an error as the id does not exist

image

jon-nfc commented 1 month ago

Now in the linked items it shows $service-16

where?

so did the item link or is this in a comment

jon-nfc commented 1 month ago

agreed this should not occur.

jon-nfc commented 3 weeks ago

TBH I don't know how this bug is even possible Using a scenario of linking a non-existing item.

The logic was setup purposely to to try and fetch the item by the id provided in the command, if the item does not exist an exception is thrown which prevents linking the item to the ticket.

https://github.com/nofusscomputing/centurion_erp/blob/dfdc5bac9d501b30c126c3fdf247db73ff243af5/app/core/lib/slash_commands/linked_model.py#L129-L146

The above code has not changed since it was initially introduced.

The only way i see this occurring is the item was linked and later removed. This scenario will create what you have reported.

Within the current test env (v1.3.0) I can't link an item that does not exist.

Test cases have been added in e9d5b081c440cbc1944787122d8022cb7278c6c2 to ensure that there is no regression in the requirement, dont link non-existing item to ticket

I'm going to assume that what has occured is that the item was linked when it was created, then subsequently deleted. I will add some test cases to ensure that when an item is deleted, the linking to tickets is also cleaned up.

jon-nfc commented 2 weeks ago

Added fix in dc55883584f3577a58870687bffa81815dbefc7d to correct the issue where when an item that may be linked to a ticket is deleted, the ticket link is also removed.

Test Cases added in e170226fbf7a4f3035ed54a9b1aa7107880bd498 to ensure there is no regression in the requirement "when an item is deleted, remove the ticket link".

This issue will be resolved on release of #344.