Schema - Fix crash when editing a field with a null description#4197
Conversation
Fields whose description is null (legacy and API-created fields store it as null) crashed the Add/Edit Field modal on open with "Cannot read properties of null (reading 'length')". PR #4127 added a length validation to the description field, routing its value through getErrorMessage, which called value.length without guarding against null. Guard the length check so a null value is treated as no error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review: Schema - Fix crash when editing a field with a null descriptionSummaryThis is a targeted, correct crash fix. The root cause analysis in the PR description is accurate: The added IssuesMinor — type annotation doesn't reflect reality
newErrorsObj[inputName] = getErrorMessage({
value: formData[inputName] as string, // null slips through here
...
});The Observations
VerdictThe fix is correct and appropriately scoped. Approve pending the type annotation note (can be addressed here or as a fast follow-up). |
Code ReviewOverviewMinimal, targeted fix for a crash introduced by PR #4127. When CorrectnessThe fix is correct and handles the crash site precisely. A One issue: type annotation does not include
|
Coverage ReportOverall Coverage
Changed Files Coverage
|
|
Sentry Issue: MANAGER-UI-3DF |
Summary
Editing (or opening the Add/Edit modal for) a Schema field whose
descriptionisnullcrashes the app with:descriptionisnullfor legacy and API-created fields (the API only stores a string once one is entered). Most fields created before the description field existed havenullhere.Root cause
PR #4127 ("Schema: Add frontend validation for description field length", merged to
dev2025-05-28, reachedstable2025-07-01) addedmaxLength: 500andvalidate: ["length"]to thedescriptionconfig entry. That routeddescription's value throughgetErrorMessagefor the first time.descriptionis the only validated input whose hydrated form value can benull(name/labelare required non-null;tooltipis explicitly coerced to""). The length check calledvalue.lengthwithout a null guard.Fix
Guard the length check in
getErrorMessageso anull/empty value is treated as no error. This is the actual crash site and protects any nullable validated field, not justdescription.closes #4196