fix(drivers): avoid mutating caller input options in fs-lite and db0 - #788
Conversation
Instead of overwriting opts.base with resolve(opts.base), create a local const to hold the resolved base path. This prevents unexpected mutation of the caller's options object. Fixes unjs#566
Instead of overwriting opts.tableName with the default value, create a local const to hold the resolved table name. This prevents unexpected mutation of the caller's options object. Also thread tableName through to setupTable() as a parameter instead of relying on the options object. Fixes unjs#566
|
Warning Review limit reached
Next review available in: 44 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe db0, fs-lite, and PlanetScale drivers now resolve configuration values locally instead of mutating input options. db0 passes resolved database and table values to table setup. Regression tests verify option preservation. ChangesOpts mutation removal
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change prevents two drivers from mutating caller-provided options without indicating a new user or production impact; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ions Keeps `driver.options` (used by tracing) reporting the resolved base and default table name, without mutating the caller's object. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…tate-input-options # Conflicts: # src/drivers/planetscale.ts
Problem
Fixes #566
Two drivers were mutating the caller's input
optionsobject, which can cause unexpected side-effects when the same options object is reused or inspected after driver creation.fs-litedriverThe
fs-litedriver overwroteopts.basewithresolve(opts.base), modifying the original object passed in by the caller.db0driverThe
db0driver wrote a default value back intoopts.tableName, modifying the original object passed in by the caller.Fix
In both cases, the mutation is replaced with a local
constthat holds the resolved/defaulted value, leaving the caller's object untouched:For
db0,tableNameis also passed as an explicit argument tosetupTable()instead of reading it from the options object inside that function.Note: the
fs.tsdriver already handles this correctly by usingconst base = resolve(userOptions.base)without touchinguserOptions.Changes
src/drivers/fs-lite.ts: replaceopts.base = resolve(opts.base)withconst base = resolve(opts.base)and update all usagessrc/drivers/db0.ts: replaceopts.tableName = opts.tableName || DEFAULT_TABLE_NAMEwithconst tableName = ...and thread it through tosetupTable()Summary by CodeRabbit
Bug Fixes
Reliability