Skip to content

Conversation

@Retoocs
Copy link
Contributor

@Retoocs Retoocs commented Oct 9, 2025

Description

Fixed setting empty options to a data field

Fixes NAE-2225

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

Manually by custom process:

  • tested from action by setData("t_panel", otherCase, ["test_enumeration": ["value": "", "options": [:], "type": "enumeration_map"]])
  • checked data field in database
  • also tested DataRef of such data field with empty options in database

Test Configuration

Name Tested on
OS Ubuntu 24.04.1 LTS
Runtime Java 11
Dependency Manager Maven 3.6.3
Framework version Spring Boot 2.7.8
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of empty option lists to avoid null-related errors and unexpected behavior.
    • Ensures UI components gracefully display when no options are available.
  • Refactor

    • Simplified internal option parsing for more consistent behavior and easier maintenance.

- fix setting empty options in DataService
@Retoocs Retoocs self-assigned this Oct 9, 2025
@Retoocs Retoocs added bugfix A change that fixes a bug Extra Small labels Oct 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Revises DataService.parseOptions to directly return mapper.convertValue with an inferred TypeReference, removing the explicit empty-map check and the null-return path.

Changes

Cohort / File(s) Summary
parseOptions refactor
src/main/java/com/netgrif/application/engine/workflow/service/DataService.java
Simplified JSON-to-Map conversion: replaced explicit Map creation and empty-check/null return with direct mapper.convertValue using new TypeReference<>() {}; method now returns the conversion result, including possible empty map.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly states that the change addresses a bug preventing empty options from being set via setData, which matches the core modification in DataService.parseOptions to return empty maps instead of null when no options are provided.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14eeaa1 and dce6d0b.

📒 Files selected for processing (1)
  • src/main/java/com/netgrif/application/engine/workflow/service/DataService.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: Build
🔇 Additional comments (2)
src/main/java/com/netgrif/application/engine/workflow/service/DataService.java (2)

1048-1060: LGTM! Fix correctly enables empty options to be set.

The change removes the explicit empty-map check that previously returned null for empty options. Now parseOptions returns an empty map when optionsNode is empty, which allows the caller (setData at line 271) to proceed with setting empty options via setDataFieldOptions. This directly addresses the reported issue NAE-2225.

The use of diamond operator in new TypeReference<>() {} is valid and maintains type safety through inference.


1048-1060: Empty-options path is safe but verify persistence

  • DataField.setOptions/setChoices accept empty collections and setDataFieldOptions correctly handles both map and enum/multichoice types without side effects
  • Confirm your JPA mapping and DataRef handling persist empty collections as intended in the database

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix A change that fixes a bug Extra Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants