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] Fix parse_exception: request body is required (#6552) #6788

Merged
merged 1 commit into from Apr 29, 2024

Conversation

SouadHadjiat
Copy link
Member

@SouadHadjiat SouadHadjiat commented Apr 23, 2024

Proposed changes

  • add a test on body length before calling elBulk

Related issues

Issue not reproduced locally

Checklist

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

@SouadHadjiat SouadHadjiat added the filigran team use to identify PR from the Filigran team label Apr 23, 2024
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.06%. Comparing base (e8ca0e1) to head (3396f5d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6788   +/-   ##
=======================================
  Coverage   68.06%   68.06%           
=======================================
  Files         538      538           
  Lines       65801    65803    +2     
  Branches     5578     5578           
=======================================
+ Hits        44786    44788    +2     
  Misses      21015    21015           

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

@SouadHadjiat SouadHadjiat marked this pull request as ready for review April 25, 2024 12:39
@@ -3162,7 +3162,9 @@ const elRemoveRelationConnection = async (context, user, elementsImpact) => {
});
});
const bodyUpdate = R.flatten(bodyUpdateRaw);
await elBulk({ refresh: true, timeout: BULK_TIMEOUT, body: bodyUpdate });
if (bodyUpdate.length > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we investigate why we don't have a body rather ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't have time to investigate in details, I guessed the relationships we try to delete have already been deleted. But if you think we should take more time to fix this issue, let me know.

Copy link
Member

Choose a reason for hiding this comment

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

It's not about time spent on task it's about knowing what we are fixing.

I'm always afraid of that kind of fix because it might be hidding a real root cause that we will keep having.

Copy link
Member Author

Choose a reason for hiding this comment

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

I understand, but in this code, we have no way of knowing that we will find all the relationships we want to delete in the database. We have the same condition in elIndexElements :

if (bodyUpdate.length > 0) {
  const bulkPromise = elBulk({ refresh: true, timeout: BULK_TIMEOUT, body: bodyUpdate });
  await Promise.all([bulkPromise]);
}

What do you think @richard-julien ? did I miss something about this code ?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like we have a condition when the list can be empty

          if (isEmptyField(fromIndex)) { // No need to clean up the connections if the target is already deleted.
            return updates;
          }

If i remember well is a condition to optimize the number of operation to execute, so can be empty in some conditions
Im ok with the fix.

Copy link
Member

@aHenryJard aHenryJard left a comment

Choose a reason for hiding this comment

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

Looks good to me after reading all comments in the PR.

@SouadHadjiat SouadHadjiat merged commit 6c63a01 into master Apr 29, 2024
5 checks passed
@SouadHadjiat SouadHadjiat deleted the issue/6552 branch April 29, 2024 13:51
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.

parse_exception: request body is required when Retention Policy is executed
4 participants