question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deletion of labels does not affect label references on labeled reports

See original GitHub issue

Description

Deleting a label that is used will not remove its references from reports, causing errors when reports are listed in the frontend.
Statistics on the Dashboard are also affected as referenced label does not exist

Environment

  1. OS: Ubuntu 18.04.5 LTS
  2. OpenCTI version: 4.0.7
  3. OpenCTI client: frontend
  4. Other environment details: Running in Docker Stack on Docker 20.10.2, build 2291f61

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. Go to “Settings"→"Labels & Attributes” in the web frontend
  2. Click the dots and click “delete”
  3. Go to “Activities"→"Analysis”
  4. Go to “Dashboard”

Expected Output

Label should be deleted along with references to it.
Reports should be visible under Analysis, but now without the deleted tag.
Dashboard widget for “Top labels” should reflect labels except those deleted.

Actual Output

Step 3 is giving error message in the frontend: “An unknown error occurred. Please contact your administrator or the OpenCTI maintainers.”
Step 4: Dashboard struggles to load widget for “Top labels” (and possibly “Top Active Entities”). The page keeps reloading every second.

Additional information

Docker log entry from opencti_opencti container after attempting to load the “Analysis” page in the frontend:

opencti_opencti.1.yww3ckzxusp1@hostname | {"user":{"ip":"::****:*.*.*.*","user_id":"************"},"type":"READ_ERROR","operation_query":"query ReportsLinesPaginationQuery($search:String$count:Int!$cursor:ID$orderBy:ReportsOrdering$orderMode:OrderingMode$filters:[ReportsFiltering]){...ReportsLines_data_2wN0PW}fragment ReportLine_node on Report{id name published x_opencti_report_status createdBy{__typename ...on Identity{__isIdentity:__typename id name entity_type}}objectMarking{edges{node{id definition x_opencti_color}}}objectLabel{edges{node{id value color}}}}fragment ReportsLines_data_2wN0PW on Query{reports(search:$search first:$count after:$cursor orderBy:$orderBy orderMode:$orderMode filters:$filters){edges{node{id name published createdBy{__typename ...on Identity{__isIdentity:__typename id name entity_type}}objectMarking{edges{node{id definition}}}...ReportLine_node __typename}cursor}pageInfo{endCursor hasNextPage globalCount}}}","inner_relation_creation":0,"operation":"ReportsLinesPaginationQuery","time":53,"variables":{"search":"","count":25,"cursor":null,"orderBy":"published","orderMode":"desc","filters":[{"key":"report_types","values":["MISP Event"],"operator":"eq"}]},"size":154,"error":{"stacktrace":["Error: Cannot return null for non-nullable field LabelEdge.node.","at completeValue (/opt/opencti/node_modules/graphql/execution/execute.js:561:13)","at resolveField (/opt/opencti/node_modules/graphql/execution/execute.js:474:19)","at executeFields (/opt/opencti/node_modules/graphql/execution/execute.js:294:18)","at collectAndExecuteSubfields (/opt/opencti/node_modules/graphql/execution/execute.js:749:10)","at completeObjectValue (/opt/opencti/node_modules/graphql/execution/execute.js:739:10)","at completeValue (/opt/opencti/node_modules/graphql/execution/execute.js:592:12)","at /opt/opencti/node_modules/graphql/execution/execute.js:626:25","at from (<anonymous>)","at completeListValue (/opt/opencti/node_modules/graphql/execution/execute.js:613:49)","at completeValue (/opt/opencti/node_modules/graphql/execution/execute.js:574:12)","at resolveField (/opt/opencti/node_modules/graphql/execution/execute.js:474:19)","at executeFields (/opt/opencti/node_modules/graphql/execution/execute.js:294:18)","at collectAndExecuteSubfields (/opt/opencti/node_modules/graphql/execution/execute.js:749:10)","at completeObjectValue (/opt/opencti/node_modules/graphql/execution/execute.js:739:10)","at completeValue (/opt/opencti/node_modules/graphql/execution/execute.js:592:12)","at /opt/opencti/node_modules/graphql/execution/execute.js:471:16"]},"level":"error","message":"API Call","timestamp":"2021-01-19T14:33:43.528Z"}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
richard-juliencommented, Jan 29, 2021

Finally the implementation will iterate and remove everything. So if you have a lot of elements it can take some times. The API is not designed to do massive update or delete for now, so if your front timeout waiting for the answer, be careful to not click again on the button 😃

For the data you have, the release will have a specific yarn command to clear the broken data if you want to.

1reaction
richard-juliencommented, Jan 22, 2021

@crym ,

The code had a limitation and only delete 1000 related elements connected to the element before deleting it, with the effect to let some relations linked to deleted data.

I change the behavior to delete the target only of all related elements are deleted, with the hard limit of 5000 to prevent locking the platform with very large delete.

So if you want to delete a label linked to 10 000 reports, you will have to ask 2 times for the deletion. (After the first one the element will be display again after refresh because only 5000 elements will be deleted the first time)

Now for your current platform that is “broken”. Can you start from scratch or do you need to cleanup the data?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learn about sensitivity labels - Microsoft Purview (compliance)
Learn how sensitivity labels from Microsoft Purview Information Protection can protect your organization's sensitive content, wherever it's ...
Read more >
List of Allowable Changes to Approved Labels - TTB
YOU MAY... WINE DISTILED SPIRITS MALT BEVERAGE YES YES YES 10. Change the net contents statement. YES YES YES 31. Delete all organic references from the...
Read more >
Deleting labels | BigQuery - Google Cloud
For each label you want to delete, click delete (X). To save your changes, click Update.
Read more >
Converting labels to annotation—Help | ArcGIS for Desktop
Then, if you move the feature, the annotation (label) moves with it; if you delete the feature, the annotation is also deleted; and...
Read more >
Labels - GitLab Docs
It does not list any labels created in the group's projects. ... All references to the label are removed from the system and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found