Skip to content

Conversation

@doppleware
Copy link

This PR fixes an IllegalStateException occurring in the /owners/{ownerId}/pets endpoint when an owner has multiple pets. The issue was caused by using Collectors.toMap() which doesn't support multiple values for the same key.

Changes made:

  • Modified the stream collection logic in getOwnerPetsMap to use Collectors.groupingBy
  • This change properly handles the one-to-many relationship between owners and pets
  • Prevents the duplicate key exception when an owner has multiple pets

The fix ensures that all pets for an owner are properly grouped into a list instead of attempting to create a one-to-one mapping.

Related error ID: bebfa1a8-3ba0-11f0-a505-42975a299f33

@doppleware doppleware closed this Jun 2, 2025
@doppleware doppleware deleted the fix-owner-pets-mapping-created-by-agentic branch June 2, 2025 16:08
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.

2 participants