Skip to content

sqlite: validate maxSize argument in createTagStore() - #63792

Open
Anshikakalpana wants to merge 1 commit into
nodejs:mainfrom
Anshikakalpana:fix/sqlite-createTagStore-maxSize-validation
Open

sqlite: validate maxSize argument in createTagStore()#63792
Anshikakalpana wants to merge 1 commit into
nodejs:mainfrom
Anshikakalpana:fix/sqlite-createTagStore-maxSize-validation

Conversation

@Anshikakalpana

@Anshikakalpana Anshikakalpana commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Fixes: #63791

database.createTagStore() accepted invalid values for its maxSize argument without throwing. Negative integers caused integer overflow, NaN and floats produced garbage capacity values, and strings were silently ignored.

The maxSize parameter is documented as {integer} and represents a cache size, so negative values are meaningless.

This PR adds validation to reject:

  • Non-integer values (NaN, floats, strings) with ERR_INVALID_ARG_TYPE
  • Negative integers with ERR_OUT_OF_RANGE

Edit: non-integer values (NaN, floats, strings) no longer throw ERR_INVALID_ARG_TYPE.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/sqlite

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Jun 8, 2026
@Anshikakalpana
Anshikakalpana force-pushed the fix/sqlite-createTagStore-maxSize-validation branch from 68d5139 to 3c0477b Compare June 8, 2026 11:23
Comment thread src/node_sqlite.cc Outdated
Comment thread src/node_sqlite.cc Outdated
Comment on lines +124 to +129
code: 'ERR_INVALID_ARG_TYPE',
message: /maxSize/,
});

assert.throws(() => db.createTagStore(1.5), {
code: 'ERR_INVALID_ARG_TYPE',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely be ERR_OUT_OF_RANGE, like e.g. node -e 'child_process.spawn("/dev/null", { uid: 1.3 })' does

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — floats now throw ERR_OUT_OF_RANGE instead of ERR_INVALID_ARG_TYPE.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Anshikakalpana Can you update the PR description to include this change?
The non-integer values (NaN, floats, strings) no longer throw ERR_INVALID_ARG_TYPE

@Anshikakalpana
Anshikakalpana force-pushed the fix/sqlite-createTagStore-maxSize-validation branch from 3c0477b to 406e215 Compare June 9, 2026 07:32
@Anshikakalpana

Copy link
Copy Markdown
Contributor Author

Hi @aduh95! I addressed all the review comments and updated the PR. Could you please take another look when you have a chance? Thanks!

@trivikr

This comment was marked as outdated.

@Anshikakalpana
Anshikakalpana force-pushed the fix/sqlite-createTagStore-maxSize-validation branch from 406e215 to b81b873 Compare August 7, 2026 12:47
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.30%. Comparing base (8fc7341) to head (6371aa2).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63792      +/-   ##
==========================================
- Coverage   90.31%   90.30%   -0.02%     
==========================================
  Files         759      759              
  Lines      248288   248302      +14     
  Branches    46857    46858       +1     
==========================================
- Hits       224247   224223      -24     
- Misses      15471    15514      +43     
+ Partials     8570     8565       -5     
Files with missing lines Coverage Δ
src/node_sqlite.cc 81.13% <100.00%> (+0.08%) ⬆️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trivikr
trivikr requested a review from aduh95 August 7, 2026 14:55
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2026
Comment thread src/node_sqlite.cc Outdated
@trivikr trivikr removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2026
@Anshikakalpana
Anshikakalpana force-pushed the fix/sqlite-createTagStore-maxSize-validation branch from b81b873 to de6789b Compare August 7, 2026 20:12
Signed-off-by: anshikakalpana <anshikajain196872@gmail.com>
@Anshikakalpana
Anshikakalpana force-pushed the fix/sqlite-createTagStore-maxSize-validation branch from de6789b to 6371aa2 Compare August 7, 2026 20:21
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite: createTagStore() accepts invalid maxSize values (negative , NaN , float)

4 participants