Skip to content

Comments

Fix record field selector issues for nested record members #726

Open
TharmiganK wants to merge 4 commits into1.7.xfrom
persist-fixes-1.7.x
Open

Fix record field selector issues for nested record members #726
TharmiganK wants to merge 4 commits into1.7.xfrom
persist-fixes-1.7.x

Conversation

@TharmiganK
Copy link
Contributor

@TharmiganK TharmiganK commented Feb 21, 2026

Description

Fixes: wso2/product-ballerina-integrator#2537

Fixes three bugs in the record field selector when working with nested record types:

  • Missing refs for nested members: When merging source and target record selector types, refs from the source member were not being propagated, causing nested record field selector members to lose their type references.
  • Missing text edit for new nested record members: The dependent type (inferred from the function parameter) was carrying lineRange on its referenced types, which caused the type update logic to treat them as existing types and skip generating text edits for newly selected nested record members. Introducing the isDependentType flag strips lineRange from those referenced types so new types are correctly written.
  • Wrong generated type name: Type names for generated nested record types were derived from the referenced type name instead of the field name, producing names like resultAlbumOptionalizedType instead of the expected resultAlbumsType.

Summary

This pull request addresses three bugs in the record field selector when processing nested record types:

Core Fixes

Reference Propagation for Nested Members: Modified the type merging logic to preserve references from source members when combining source and target record selector types. This ensures nested record field selector members retain their type references during the merge process.

Type Inference for New Nested Members: Introduced an isDependentType parameter to the getRecordSelectorType method. When enabled, the parameter drops line-range information from dependent record types by removing location metadata. This prevents the type update logic from incorrectly treating newly selected nested members as existing types and ensures text edits are properly generated for new nested record definitions.

Type Name Generation: Fixed the naming logic for generated nested record types to derive names from the field name rather than the referenced type name, producing correct output such as resultAlbumsType instead of resultAlbumOptionalizedType.

Implementation Changes

  • Updated TypesManager.java to add the isDependentType parameter and implement the fixes for reference propagation and type name derivation
  • Updated CallBuilder.java to pass the appropriate boolean flag when invoking the modified getRecordSelectorType method
  • Updated test fixtures and resource files to reflect the behavior changes, including removal of line-range metadata from dependent types

Dependency Updates

  • Updated the ballerina:log package version from 2.16.1 to 2.17.0 in test configurations and gradle properties

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch persist-fixes-1.7.x

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

@TharmiganK TharmiganK marked this pull request as ready for review February 22, 2026 15:29
@samithkavishke
Copy link
Contributor

@TharmiganK , can you attach the issue that this PR addresses?

@TharmiganK
Copy link
Contributor Author

@TharmiganK , can you attach the issue that this PR addresses?

Updated the PR description with the issue

Copy link
Contributor

@pasindufernando1 pasindufernando1 left a comment

Choose a reason for hiding this comment

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

@TharmiganK You can get the latest changes from 1.7.x. The log version bump is already done and merged

@TharmiganK
Copy link
Contributor Author

@TharmiganK You can get the latest changes from 1.7.x. The log version bump is already done and merged

Ack, merged with 1.7.x branch

Copy link
Contributor

@pasindufernando1 pasindufernando1 left a comment

Choose a reason for hiding this comment

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

Shall we add test cases to cover the three bugs addressed here?

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.

3 participants