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

[backend] avoid user deletion raising exception when authorized_member is missing (#5580) #5747

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

aHenryJard
Copy link
Member

@aHenryJard aHenryJard commented Jan 30, 2024

Proposed changes

  • From this piece of error logs on the issue:
{"message":"Cannot read properties of undefined (reading 'some')","name":"TypeError","stack":"TypeError: Cannot read properties of undefined (reading 'some')\n    at isUserTheLastAdmin (/opt/opencti/build/src/domain/user.js:734:49)\n    at /opt/opencti/build/src/domain/user.js:746:34\n    at Array.filter (<anonymous>)\n    at deleteAllWorkspaceForUser (/opt/opencti/build/src/domain/user.js:746:6)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at userDelete (/opt/opencti/build/src/domain/user.js:831:3)"}

I think it's because authorized_member is undefined. Not sure why it happen but it should not prevent from user deletion.

  • I'm proposing to delete the Workspace when authorized_member is undefined, if you prefer to just skip it (maybe safer) please tell me.

Reproduced with the test before changing code
image

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@aHenryJard aHenryJard linked an issue Jan 30, 2024 that may be closed by this pull request
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (605eb54) 66.14% compared to head (8fe3e6d) 66.15%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5747      +/-   ##
==========================================
+ Coverage   66.14%   66.15%   +0.01%     
==========================================
  Files         513      513              
  Lines       60805    60809       +4     
  Branches     4447     4450       +3     
==========================================
+ Hits        40220    40229       +9     
+ Misses      20585    20580       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aHenryJard aHenryJard marked this pull request as ready for review January 30, 2024 12:15
@aHenryJard aHenryJard added the filigran team use to identify PR from the Filigran team label Jan 30, 2024
@SamuelHassine SamuelHassine merged commit 38cb81a into master Jan 30, 2024
8 checks passed
@SamuelHassine SamuelHassine deleted the issue/5580 branch January 30, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Account deletion error
2 participants