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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion opencti-platform/opencti-graphql/src/database/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

await elBulk({ refresh: true, timeout: BULK_TIMEOUT, body: bodyUpdate });
}
}
}
};
Expand Down