Skip to content

Fix IllegalStateException in GET /owners/pets endpoint-created-by-agentic #91

Description

@shaykeren

An IllegalStateException is occurring in the GET /owners/pets endpoint when an owner has multiple pets. This is due to the use of Collectors.toMap() which doesn't handle duplicate keys properly.

Root Cause:

  • The getOwnerPetsMap method uses Collectors.toMap() which throws IllegalStateException on duplicate keys
  • Multiple pets belonging to the same owner cause duplicate owner_id keys

Fix:

  • Modified the code to use Collectors.groupingBy instead of Collectors.toMap
  • Added proper handling of multiple pets per owner
  • Improved error handling and logging

Related PR: #90

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions