fix(checkbox): guard against null uncheckedValue when JCR property is absent#1892
Merged
Conversation
… absent When enableUncheckedValue=true but uncheckedValue is not stored in JCR (e.g. because the content push mechanism skipped an empty-string value), AbstractCheckboxImpl built an enum array with null as the second element. The AFB runtime calls .toString() on every enum value at init time, so enum: [".", null] caused TypeError: Cannot read properties of null (reading 'toString') in createFormInstance / RuleEngineWorker, crashing the form before any screen rendered. Fix: default safeUncheckedValue to "" when the JCR property is absent. Add a regression test with a fixture that omits uncheckedValue from JCR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c9d16e1 to
5e8262f
Compare
Accessibility Violations Found
|
Accessibility Violations Found
|
Accessibility Violations Found
|
Accessibility Violations Found
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
prateek1497
added a commit
that referenced
this pull request
May 29, 2026
* Updating style selectors for theme editor * Updating style selectors further * Merge pull request #1872 from adobe/fix/FORMS-25246-fieldtype-containers feat(dialog): add fieldType hidden field to container component dialogs * fix(checkbox): guard against null uncheckedValue when JCR property is absent (#1892) When enableUncheckedValue=true but uncheckedValue is not stored in JCR (e.g. because the content push mechanism skipped an empty-string value), AbstractCheckboxImpl built an enum array with null as the second element. The AFB runtime calls .toString() on every enum value at init time, so enum: [".", null] caused TypeError: Cannot read properties of null (reading 'toString') in createFormInstance / RuleEngineWorker, crashing the form before any screen rendered. Fix: default safeUncheckedValue to "" when the JCR property is absent. Add a regression test with a fixture that omits uncheckedValue from JCR. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(af-core): FORMS-25463 expose cq:annotations parallel to fd:dor (#1883) * feat(af-core): FORMS-25463 expose cq:annotations parallel to fd:dor Add getCqAnnotations() on AbstractFormComponentImpl that reads the cq:annotations child resource (a sibling of fd:dorContainer on the component node) and exposes its child annotations as a per-annotation map keyed by node name. Each entry carries color, text, x, y, optional state/resolvedBy/resolvedAt and the JCR audit fields. Null fields are stripped so the serialised shape matches the JCR content exactly. Wire the call into getProperties() so the resulting map is placed under properties.cq:annotations -- parallel to fd:dor / fd:path / fd:associate -- not nested inside dorContainer. Returns null when no cq:annotations child exists; Jackson then omits the key, keeping the output non-breaking for forms without annotations. * fix(af-core): FORMS-25463 exclude cq:annotations from getCustomProperties getCustomProperties() reads all non-reserved JCR properties from the resource ValueMap and includes them as raw Strings. cq:annotations is not in the excluded-prefix list ("fd:", "jcr:", "sling:"), so a stale String-typed cq:annotations property on the node was leaking through and appearing as a double-serialised JSON string in the GET IC response. Adding an explicit key exclusion for CUSTOM_ANNOTATIONS_PROPERTY_WRAPPER ensures the property is handled exclusively by getCqAnnotations(), which returns it as Map<String,Object> and produces proper nested JSON. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(af-core): FORMS-25463 ic annotations in authoring crispr only * style(af-core): FORMS-25463 apply formatter to AbstractFormComponentImpl Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(af-core): FORMS-25463 ic annotations in authoring crispr only * fix(af-core): FORMS-25463 remove formatting changes, keep only cq:annotations feature * FORMS-25463: blocking publish of cq:annotations * FORMS-25463: adding tests * FORMS-25463: adding more tests for codecov * FORMS-25463: formatting fix * FORMS-25463: PR comments incorporate plus tests --------- Co-authored-by: Prateek Awasthi <prateekawast@adobe.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Muskan Gupta <muskgupta@Muskans-MacBook-Pro.local> Co-authored-by: Varun Dua <vdua@adobe.com> Co-authored-by: muskgupta <muskgupta@adobe.com> Co-authored-by: Rishi Mehta <69448117+rismehta@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Prateek Awasthi <prateekawast@adobe.com>
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.
Summary
enableUncheckedValue=trueanduncheckedValueis empty string, content push mechanisms omit empty-string properties when writing to JCR. The property is absent, so@ValueMapValue(OPTIONAL)injectsnull.AbstractCheckboxImpl.initBaseCheckboxModel()buildsenum: [".", null]..toString()on every enum value at init —null.toString()throwsTypeErrorincreateFormInstance/RuleEngineWorker, crashing the form before any screen renders.uncheckedValueto""when the JCR property is absent.checkbox-enableUncheckedValueMissingFromJcromitsuncheckedValuefrom JCR; assertsgetEnums()returns[".", ""]not[".", null].Why af-form-json-converter did not catch this
The converter loads form JSON via
context.load().json()into a mock JCR (HashMap-backed). The mock stores the literal empty string and returns it to the Sling model. Real AEM never receives that empty string because the push pipeline drops empty-string properties — so the property is absent anduncheckedValueis injected asnull.Test plan
CheckBoxImplTest#shouldUseEmptyStringWhenUncheckedValueMissingFromJcrpassesCheckBoxImplTesttests still passGenerated with Claude Code