Skip to content

FIX Internal server error when passes an invalid president ID #115#121

Open
rusiru-erandaka wants to merge 4 commits into
LDFLK:mainfrom
rusiru-erandaka:Internal_server_error_on_presidentID
Open

FIX Internal server error when passes an invalid president ID #115#121
rusiru-erandaka wants to merge 4 commits into
LDFLK:mainfrom
rusiru-erandaka:Internal_server_error_on_presidentID

Conversation

@rusiru-erandaka

Copy link
Copy Markdown
Contributor

Summary

Fixes the Internal Server Error returned by the active-portfolio-list endpoint when an invalid president ID is passed as a query parameter.

Solution

Added a president existence validation at the beginning of the try block in the active_portfolio_list method, before fetching the active relationships.

  • Calls opengin_service.get_entities(Entity(id=president_id)) to verify the president exists
  • If the entity is not found, raises a NotFoundException with a clear message instead of an unhandled InternalServerError
  • If the entity is valid, proceeds with the existing logic unchanged

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a validation step to the active_portfolio_list method in organisation_service.py to ensure the president exists before retrieving active portfolios, along with corresponding unit tests. The feedback points out that get_entities raises a NotFoundError instead of returning an empty list or None when an entity is missing. Consequently, the check if not president_node_data: is redundant. The reviewer suggests catching the NotFoundError and re-raising it with a custom message, and updating the unit test mock to raise NotFoundError to accurately simulate the service's behavior.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/services/organisation_service.py Outdated
Comment thread test/test_organisation_service.py Outdated
rusiru-erandaka and others added 2 commits July 9, 2026 14:48
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@rusiru-erandaka

Copy link
Copy Markdown
Contributor Author

Hi @ChanukaUOJ , is there any issue in this PR that i want to be update ??

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.

[BUG][API] Internal server error when passes an invalid president ID

1 participant