Skip to content

Conversation

kushboojain-iplit
Copy link
Contributor

@kushboojain-iplit kushboojain-iplit commented Jan 16, 2025

BAH-4159
This PR fixes the bug - Not all privileges are loaded when assigning to forms as the API is paginated.
Fetching all the privileges and then assigning it to the dropdown

BAH-4186
This PR also fixes the bug - Not all forms are loaded in thr form builder list page as the API is paginated

collectAllPrivileges(initialPrivileges, allPrivileges) {
allPrivileges.push(...initialPrivileges.results);
if (initialPrivileges.links.length > 0 && initialPrivileges.links.find(link => link.rel === "next") !== undefined) {
httpInterceptor.get(initialPrivileges.links[0].uri)

Choose a reason for hiding this comment

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

What happens if the API has a bug? If the API incorrectly keeps returning a "next" link indefinitely, this function never stops calling itself. Could introducing a limit be a safer option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can introduce a limit but its like we are not trusting our systems.

Choose a reason for hiding this comment

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

It's always a good practice to introduce a limit. It's not that we are not trusting our systems but it's defensive programming to avoid rare but critical issues. Logic wise, it's all good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll go ahead and add a limit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arshiyaTW2021 I have added the limit.

@mohan-13 mohan-13 merged commit 8a6d9c0 into Bahmni:master Mar 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants