Skip to content

Fix IllegalStateException in owner pets mapping-created-by-agentic #97

@doppleware

Description

@doppleware

An IllegalStateException is occurring in the /owners/{ownerId}/pets endpoint when attempting to map pet IDs to owner IDs. The error indicates a duplicate key conflict when trying to merge values for owners with multiple pets.

Error details:

  • Error ID: bebfa1a8-3ba0-11f0-a505-42975a299f33
  • Type: IllegalStateException
  • Location: Collectors.duplicateKeyException
  • Endpoint: /owners/{ownerId}/pets
  • Error message: Duplicate key 3 (attempted merging values [3] and [4])

Root cause:
The current implementation uses Collectors.toMap() which doesn't support multiple values for the same key, but the database structure allows multiple pets per owner.

Fix:
A PR has been created (#96) that modifies the stream collection logic to use Collectors.groupingBy instead, which properly handles the one-to-many relationship between owners and pets.

Impact:
This issue causes the /owners/{ownerId}/pets endpoint to fail when attempting to retrieve pets for owners who have multiple pets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions