fix: prevent edge function crashes with null checks and type validation#174
Merged
Conversation
Fixes uncaught exceptions in edge functions: proxy-api-docs.js: - Add null check before head.appendChild() to prevent crash when head element is missing - Add fallback for document.documentElement to use originalHtml if null - Add type check for error.message in fetchWithRetry to handle non-Error exceptions feedback-api.ts: - Add type validation to ensure path and feedback are strings before accessing .length - Prevents crashes when invalid data types are submitted All changes maintain existing functionality while preventing edge cases that could cause crashes. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
✅ Deploy Preview for redpanda-documentation ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
micheleRP
approved these changes
May 18, 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.

Summary
Fixes uncaught exceptions in Netlify edge functions that were causing crashes in production.
Changes
proxy-api-docs.js
head.appendChild(): Prevents crash when the HTML document doesn't have a proper head element (line 174-178)document.documentElement: UsesoriginalHtmlifdocumentElementis null (line 181)fetchWithRetry: Safely handles non-Error exceptions when logging (line 217-218)feedback-api.ts
.lengthproperty, preventing crashes when invalid data types are submitted (line 35-43)Root Cause
The primary crash was caused by line 176 in
proxy-api-docs.jsattempting to callhead.appendChild(style)without checking ifheadwas null. When widget files failed to load (as shown in logs), the code continued processing but hit this unchecked operation and threw an uncaught exception.Testing
All changes maintain existing functionality while adding safety checks for edge cases:
🤖 Generated with Claude Code