Skip to content

(fix) O3-5644: Use APIException with translatable message code for queue entry concurrency errors#112

Open
sanks011 wants to merge 1 commit into
openmrs:mainfrom
sanks011:fix/O3-queue-entry-conflict-409
Open

(fix) O3-5644: Use APIException with translatable message code for queue entry concurrency errors#112
sanks011 wants to merge 1 commit into
openmrs:mainfrom
sanks011:fix/O3-queue-entry-conflict-409

Conversation

@sanks011
Copy link
Copy Markdown

@sanks011 sanks011 commented May 1, 2026

Summary

The optimistic locking checks in QueueEntryServiceImpl.transitionQueueEntry() and undoTransition() currently throw a raw IllegalStateException("Queue entry was modified by another transaction"). This has two issues:

  1. IllegalStateException is not an APIException, so the RESTWS-1002 translatedMessage field does not apply - the frontend receives an untranslated English string.
  2. It doesn't follow the existing pattern in this module where validation errors use message codes from messages.properties (e.g. queue.entry.duplicate.patient).

Changes

  • Replace IllegalStateExceptionAPIException("queue.entry.error.concurrentModification", null) in both transitionQueueEntry() and undoTransition()
  • Add queue.entry.error.concurrentModification to messages.properties
  • Remove stale TODO referencing cancelled ticket O3-2988
  • Update unit tests to expect APIException

Related Issue

https://issues.openmrs.org/browse/O3-5644

Copilot AI review requested due to automatic review settings May 1, 2026 07:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates queue entry optimistic-locking/concurrency error handling so REST clients can receive translatable, message-code-based errors instead of raw English IllegalStateException strings.

Changes:

  • Replace concurrency-related IllegalStateException throws with APIException using a message code in transitionQueueEntry() and undoTransition().
  • Add a new message key queue.entry.error.concurrentModification to messages.properties.
  • Update unit tests to expect APIException for these concurrency cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java Switch concurrency error throws to APIException with a translatable message code; remove one stale TODO comment.
api/src/main/resources/messages.properties Add the new message key for concurrent modification errors.
api/src/test/java/org/openmrs/module/queue/api/QueueEntryServiceTest.java Update tests to expect APIException and add the needed import.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java Outdated
Comment thread api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java Outdated
… concurrency errors

Replace raw IllegalStateException with APIException using a translatable message code (queue.entry.error.concurrentModification) for optimistic locking failures in transitionQueueEntry() and undoTransition(). This enables the RESTWS-1002 translatedMessage field to automatically provide localized error messages.

Also removes a stale TODO referencing cancelled ticket O3-2988.
@sanks011 sanks011 force-pushed the fix/O3-queue-entry-conflict-409 branch from c3dd523 to d6bb511 Compare May 1, 2026 07:43
@sonarqubecloud
Copy link
Copy Markdown

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