Fix UI schema generation and restore enable condition delegation#36
Merged
thuva9872 merged 5 commits intowso2:1.x.x-jdk17from Apr 26, 2026
Merged
Conversation
…er enableConditions
…red member enableConditions" This reverts commit 8aef374.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
1cc9f64 to
a9bfba2
Compare
thuva9872
approved these changes
Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fix three connector schema generation bugs that cause runtime failures in generated WSO2 MI Ballerina connectors:
Union map parameter pointer mismatch — connections using a
map<string>union member (e.g.DestinationConfig|map<string>) could not be saved in MI Studio because the init.xml property pointer usedconfig_map(underscore) while both the<parameter>declaration and the uischema field name usedconfigMap(camelCase). At runtimelookupTemplateParameterreturned null, propagating as a null argument tocreateObjectValueand ultimately causing aNullPointerExceptioninside the Ballerina connector'sinitmethod.TypeDescriptor union parameter generation — when a function parameter is a
typedesc-backed union (e.g.typedesc<SomeRecord|OtherRecord>), the generated functions XML incorrectly emitted individual union member<parameter>declarations and union pointer properties as if it were a regular union. This produced spurious parameters in the Synapse template and wrong property values that the runtime could not resolve.Attribute group enable condition propagation — when all fields inside a grouped union member share the same
enableCondition, the condition was not being promoted to the enclosingattributeGroupelement. MI Studio rendered the group as always-visible even when its containing union branch was not selected.Goals
map<string>members, so the connection can be saved and the runtime can resolve the value correctly.DataTypeproperty in the Synapse template; individual member parameters and union pointer properties are suppressed, matching the runtime'stypedescresolution path.enableConditionautomatically inherit that condition (merged with any parent condition), so the group is hidden/shown correctly in MI Studio without requiring individual field conditions on every element.Approach
1. Union map pointer fix (
XmlPropertyWriter.java)writeXmlParamPropertieswas building the union member pointer value assanitizedParamName + "_map"(e.g.config_map), butwriteXmlParameterElementsandJsonGeneratorboth derive the parameter/field name assanitizedParamName + "Map"(camelCase, viaStringUtils.capitalize). Changed the format string to usesanitizedParamName + "Map"so all three are consistent:2. TypeDescriptor union template fix (
functions_template.xml)Added
{{#unless typeDescriptor}}guards around:<parameter>declarations in the template header sectionparam{{index}}Union*property block in the sequence sectionAlso corrected the
param{{index}}property value for typedesc union parameters to emit{{sanitizeParamName value}}DataType(pointing at the discriminator template parameter) rather than the bare param name, and simplified the union pointer value expression to always use{{sanitizeParamName value}}(removing the now-incorrecttypeDescriptorbranch that had been there).3. Enable condition delegation (
JsonGenerator.java)When building an
AttributeGroupfor grouped union member fields, the logic now inspects the child fields'enableConditionvalues. If all children share the same condition, that condition is promoted to the group level (merged with any parent condition on the union parameter). This replaces the previous approach of only propagating the parent's own condition, which left groups without a condition when the parent condition was null but all children had one.User stories
Type1|map<string>init parameter, the generated connection form saves successfully and the runtime resolves the map value.typedesc<T>parameters, the generated XML template does not emit unnecessary union member parameters that break runtime resolution.Release note
Fixed connector schema generation for union parameters containing
map<string>members (connection save failure due to parameter name mismatch),typedescunion parameters (spurious XML declarations causing runtime errors), and attribute group enable condition propagation (groups not correctly hidden/shown in MI Studio when a union branch is deselected).Documentation
N/A — internal schema generation fixes; no user-facing documentation change required.
Training
N/A
Certification
N/A
Marketing
N/A
Automation tests
Unit tests
XmlPropertyWriterTesttests pass.ParamHandlerTesttests pass.Integration tests
ballerinax/sap.jco) that a connection usingDestinationConfigas the union member saves successfully and theAdvancedConfig(map<string>) branch no longer causes a null argument tocreateObjectValue.Security checks
Samples
N/A
Related PRs
N/A
Migrations (if applicable)
Connectors regenerated after this fix will have a corrected
init.xmlproperty pointer (configMapinstead ofconfig_map). Existing connections created from a pre-fix connector zip must be deleted and recreated in MI Studio after redeploying the regenerated connector, as the localEntry field names are derived from the uischema at connection-creation time.Test environment
Learning
Root cause of bug #1 traced by comparing the
writeXmlParameterElementspath (which usesStringUtils.capitalizeon the member type label to produce camelCase) against thewriteXmlParamPropertiespath (which used a hardcoded underscore concatenation). The two code paths were independently written and diverged without a test that covered the full round-trip from generation through runtime resolution.