Bugfix 13653 disabling a disease variant for a disease leads to error#13923
Conversation
Otherwise user will see the unwanted error message while opening the case/case management.
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds validation to prevent removal or deactivation of customizable enum values that are currently in use by cases. A new validation constant is introduced along with a query method to detect case usage, and a guard clause is added to the save method to enforce this constraint. ChangesPrevent Removal of In-Use Customizable Enum Values
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sormas-api/src/main/resources/validations.properties`:
- Line 335: Update the message for the customizableEnumValueAlreadyInUse
property to improve clarity and consistency: replace "for %s case(IDs)" with
"used by case IDs: %s" and change the final clause to "before deleting or
deactivating" so the full message reads clearly that the customizable value is
used by specific case IDs and must be removed from them before deleting or
deactivating; locate and edit the customizableEnumValueAlreadyInUse entry in
validations.properties.
In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumFacadeEjb.java`:
- Around line 173-184: The removal guard currently skips the "remove-all" case,
only inspects one removed disease via findAny(), and incorrectly uses
dto.getValue() instead of the persisted value; update the logic in
CustomizableEnumFacadeEjb to iterate all diseases in
existingEntity.getDiseases(), treat dto.getDiseases() being null/empty as “no
remaining diseases”, and for each disease not present in dto.getDiseases() call
service.areCasesUsingCustomizableEnumValue(disease,
getEnumValue(dto.getDataType(), disease, existingEntity.getValue())) (i.e., use
existingEntity.getValue() / persisted enum value) and if any returned uuids are
non-empty throw the same ValidationRuntimeException with the joined uuids;
replace the findAny() shortcut with a full check/early-exit on first conflict.
In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumValueService.java`:
- Line 97: The integrity check in CustomizableEnumValueService uses
caseService.findBy(caseCriteria, false) which applies user/jurisdiction filters
and can miss cases; update the call to perform an unfiltered query (use the
findBy overload/flag that disables user filtering so the search ignores
jurisdiction/user constraints) so the integrity validation inspects all Case
records referenced by the enum value (change the second argument to the value
that turns off filtering or call the unfiltered findBy variant).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8145ceaf-04a2-4879-a69e-a3919b6d5ff2
📒 Files selected for processing (4)
sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.javasormas-api/src/main/resources/validations.propertiessormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumValueService.java
| smsAuthSecretValueValidation = SMS Auth secret value is not valid | ||
| systemConfigurationValueValidationInvalidBackgroundColor = Pre-defined values are: green, red, indigo, gray, default (case-sensitive) otherwise must match hexadecimal format (with or without hash "#"), example: #dd2b0e or #4AA or dd2b0e | ||
| systemConfigurationValueValidationMenuSubtitle = Can be empty or up to 16 (any) characters. Can be used to define name of the environment: PRODUCTION - TEST etc. | ||
| customizableEnumValueAlreadyInUse = The customizable value %s is being used for %s case(IDs) and therefore cannot be deleted or deactivated. Please remove all references to this value before attempting to deactivate. |
There was a problem hiding this comment.
Improve the new validation text for clarity and consistency.
At Line 335, the phrase for %s case(IDs) is hard to read, and the final sentence only mentions deactivation even though the first sentence mentions deletion too. Consider clearer wording (e.g., “used by case IDs: %s” and “before deleting or deactivating”).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@sormas-api/src/main/resources/validations.properties` at line 335, Update the
message for the customizableEnumValueAlreadyInUse property to improve clarity
and consistency: replace "for %s case(IDs)" with "used by case IDs: %s" and
change the final clause to "before deleting or deactivating" so the full message
reads clearly that the customizable value is used by specific case IDs and must
be removed from them before deleting or deactivating; locate and edit the
customizableEnumValueAlreadyInUse entry in validations.properties.
Fixes #
Summary by CodeRabbit
New Features