Fix: Exception Approval Dashboard Crashes After Approving Request
Context
After approving an exception request on the /exception-approvals dashboard, a JavaScript error crashes the component:
code
Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at ExceptionApprovalDashboard (ExceptionApprovalDashboard.tsx:333:59)
Trigger: Approve a request → pending list refreshes → 0 pending results → component crashes.
Root Cause: pendingRequests.content is undefined when the API returns an empty page. The error says undefined (not null), meaning the content key is entirely absent from the JSON response. Micronaut Serde may omit empty collections from serialization. The frontend accesses .content.length without a null guard, causing the crash.
Affected code: Both ExceptionApprovalDashboard.tsx (line 333) and MyExceptionRequests.tsx (line 287) have the same unsafe pattern: data.content.length === 0 where content can be undefined.
Fix
1. Backend: Add default value to DTO content field
Change the existing PaginatedExceptionRequestsResponse to use a default empty list, ensuring Micronaut Serde always includes the field:
kotlin
@Serdeable
data class PaginatedExceptionRequestsResponse(
val content: List<VulnerabilityExceptionRequestDto> = emptyList(),
val totalElements: Long,
val totalPages: Int
)
2. Frontend: Add null-safe access to content in both components
Navigate to /exception-approvals with 1+ pending request
Approve a request — no crash, empty state message shows, count card decreases
Navigate to /my-exception-requests — cancel a request, no crash
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/flake/.claude/projects/-Users-flake-sources-misc-secman/737ef27c-a83a-47a1-ab5f-a9b233652079.jsonl
Assistant
Let me read all three files in parallel to see the current code.
Assistant
I can see all the affected lines clearly. Let me apply all 5 fixes now.
★ Insight ─────────────────────────────────────Why this crash happens: Micronaut Serde (its JSON serializer) can omit fields with empty collections from the JSON output. When the last pending request is approved, the API returns {"totalElements": 0, "totalPages": 0} — no content key at all. The frontend then tries undefined.length and crashes. The fix is defense-in-depth: ensure the backend always serializes the field (via default value), and guard against undefined on the frontend.
─────────────────────────────────────────────────
Assistant
All 5 edits applied. Now let me verify the backend compiles.
Assistant
Build successful. All changes compile and tests pass.
Line 333: Added !pendingRequests.content || guard before .length check
Line 357: Changed .content.map to .content?.map (optional chaining)
Frontend (MyExceptionRequests.tsx:287, 315):
Line 287: Added !requests.content || guard before .length check
Line 315: Changed .content.map to .content?.map (optional chaining)
★ Insight ─────────────────────────────────────
Defense in depth: The backend fix alone would prevent the crash, but the frontend guards are still valuable — they protect against network issues, API version mismatches, or any future DTO changes that might omit content again.
Kotlin default parameters vs Serde: When Micronaut Serde serializes a Kotlin data class, it respects the actual field value. By setting emptyList() as the default, the field always has a non-null value, so Serde won't skip it. Without the default, if a constructor call omits content, Kotlin would require it — but the real issue was Serde deserializing an empty page response where the service layer might not set content at all.
Optional chaining pattern: ?.content?.map(...) is the idiomatic React/TS way to handle potentially undefined nested properties. It short-circuits to undefined, which React renders as nothing — safe and clean.
─────────────────────────────────────────────────
User
please remove the "Created at" UI vuln element
User
[Image: image/png]
User
[Image: source: /var/folders/k7/jz4z13354rlbg2yhm0vw9g2w0000gn/T/TemporaryItems/NSIRD_screencaptureui_huhq57/Screenshot 2026-03-08 at 21.04.58.png]
Assistant
The page is /vulnerabilities/exceptions, so the component is VulnerabilityExceptionsTable.tsx.
Assistant
Done. Removed the "Created At" column header and its corresponding data cell from the Vulnerability Exceptions table.
★ Insight ─────────────────────────────────────
The "Created By" column is kept since it provides useful accountability info, while "Created At" was redundant — the expiration date already gives the important temporal context for exceptions.
─────────────────────────────────────────────────
User
in the popall all the detail regarding CVEs, if the eyception is for a CVE or for a system etc missing, please propose a holistic patch plan
User
[Image: image/png]
User
[Image: source: /var/folders/k7/jz4z13354rlbg2yhm0vw9g2w0000gn/T/TemporaryItems/NSIRD_screencaptureui_gE2Zhj/Screenshot 2026-03-08 at 21.06.28.png]
Assistant
Let me read the existing plan file and explore the edit modal implementation.
Assistant
Excellent exploration. Now let me look at the exact form code to understand the edit mode rendering.
Assistant
I now have a complete understanding. The VulnerabilityExceptionForm.tsx receives the full exception object via props but in edit mode skips straight to just Expiration Date + Reason fields — no context about what is being edited. All the data is already available client-side; it just needs to be rendered.
Let me write the plan.
Assistant
The plan is ready. It's a frontend-only change (2 files) — no backend modifications needed since the API already returns all the data. The edit modal will get a read-only context section showing Type, Target, Affected count, and Created By above the existing editable fields.