bake: validate bundlerOptions is an object before property access#30579
bake: validate bundlerOptions is an object before property access#30579robobun wants to merge 1 commit into
Conversation
Bun.serve({ app: { bundlerOptions: 315 } }) would hit a debug assertion
in JSValue.get() because we called property getters on a non-object.
Also fix the same issue for bundlerOptions.{server,client,ssr} and for
the nested minify option (which also crashed on minify: false).
|
Updated 12:52 PM PT - May 12th, 2026
❌ @robobun, your commit 2652ab4 has 1 failures in
🧪 To try this PR locally: bunx bun-pr 30579That installs a local version of the PR into your bun-30579 --bun |
There was a problem hiding this comment.
LGTM — straightforward input validation to convert fuzzer-found assertion failures into proper TypeErrors, with tests.
Extended reasoning...
Overview
This PR fixes a fuzzer-discovered debug assertion in bake.zig where non-object values passed to app.bundlerOptions (or its server/client/ssr/minify sub-options) would hit reached unreachable code in JSValue.get(). The fix adds isObject() checks before property access in three locations and throws ERR_INVALID_ARG_TYPE instead. It also fixes a related bug where minify: false fell through the boolean check (which only matched true) into the object property-access path.
Security risks
None. This is purely defensive input validation on a user-facing config API — it converts crashes into proper thrown errors. No new attack surface, auth, or data handling.
Level of scrutiny
Low. The change is small (~20 lines of Zig), mechanical, and follows the exact same if (!x.isObject()) return global.throwInvalidArguments(...) pattern already used elsewhere in this file (e.g., the config check at the top of UserOptions.fromJS, the reactFastRefresh/serverComponents checks). The minify boolean refactor is a clear correctness improvement — previously isBoolean() and asBoolean() only short-circuited on true, leaving false to crash on the subsequent .getBooleanLoose() calls.
Other factors
- Four new tests in
bun-serve-args.test.tsexercise each new error path plus theminify: falseregression. throwInvalidArgumentsproducesERR_INVALID_ARG_TYPEwhich is aTypeError, matching the test assertions.- No bugs flagged by the bug-hunting system, no outstanding reviewer comments, no prior reviews on this PR.
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
|
Duplicate of #30125 which already covers all these cases with better error messages. |
Fuzzer found a debug assertion in
JSValue.get()when passing a non-object value toapp.bundlerOptionsinBun.serve().getOptional(global, "bundlerOptions", JSValue)returns the raw value without type checking, then we called.getOptional()on it which asserts the target is an object.Same issue existed for
bundlerOptions.{server,client,ssr}and for the nestedminifyoption (which also crashed onminify: falsesince the boolean check only broke out of the block whentrue). All of these now throw a properTypeError.Fingerprint:
2406707844214a48