-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Hawaii crashes with NullReferenceException when processing complex OpenAPI schemas that have nested Content["application/json"]
structures without proper null checks.
Error Example
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Hawaii.Program.processResponse(OpenApiResponse response, String operationId)
CloudflareFS Workaround
We fixed this in a local fork of Hawaii with additional null safety checks:
Files Modified: \Hawaii\src\Program.fs
, \Hawaii\src\OperationParameters.fs
// Before (crashed):
let mediaType = response.Value.Content.["application/json"]
if not (isNull mediaType.Schema) then ...
// After (works):
if not (isNull response.Value.Content) &&
response.Value.Content.ContainsKey "application/json" then
let mediaType = response.Value.Content.["application/json"]
if not (isNull mediaType) && not (isNull mediaType.Schema) then ...
Impact
- Before fix: Could not generate Workers Management API (crashed)
- After fix: Successfully generates 200KB+ of F# code for Workers API
Recommendation
The patches are straightforward defensive coding that handle edge cases in complex OpenAPI specs. A more elegant solution may be possible, but I'll post a draft PR with the fixes from my fork for your review.
Metadata
Metadata
Assignees
Labels
No labels