-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Duplicate Key Handling Issue in Obligation Creation
Description:
The API currently returns inconsistent error responses when encountering duplicate topic or text keys while creating an obligation.
Current Behavior:
- Duplicate
topic: Returns409 Conflictwith a descriptive message. - Duplicate
text: Returns400 Bad Requestwith a generic message.
Expected Behavior:
- When both
topicandtextare duplicates, the API should return a single, combined response:
{
"status": 409,
"message": "Duplicate keys error",
"error": "Obligation with topic '...' and text '...' already exists",
"path": "/api/v1/obligations",
"timestamp": "2025-03-24T22:54:33+05:30"
}- When only the
topicis duplicated:
{
"status": 409,
"message": "Duplicate topic error",
"error": "Obligation with topic '...' already exists",
"path": "/api/v1/obligations",
"timestamp": "2025-03-24T22:54:33+05:30"
}- When only the
textis duplicated:
{
"status": 409,
"message": "Duplicate text error",
"error": "Obligation with text '...' already exists",
"path": "/api/v1/obligations",
"timestamp": "2025-03-24T22:54:33+05:30"
}Solution:
- Use 409 Conflict when either
topic,text, or both are duplicates. - Return specific responses based on the duplicate case.
Impact:
- Improved API consistency.
- Easier error handling for clients.
deo002
Metadata
Metadata
Assignees
Labels
No labels