Skip to content

sqlite: throw on oversized string values - #66209

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
araujogui:sqlite-throw-on-oversized-strings
Sep 29, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
araujogui:sqlite-throw-on-oversized-strings

Conversation

@araujogui

Copy link
Copy Markdown
Member

SQLite serves TEXT up to SQLITE_MAX_LENGTH (1e9 by default), past what
V8 can represent as a string. String::NewFromUtf8() returns an empty
handle without throwing, and the user-defined function path then called
SetIgnoreNextSQLiteError(true) as if a JavaScript exception were
pending, so the SQLite error was discarded too.

db.exec('INSERT INTO t VALUES (myfn(hex(zeroblob(300000000))))');
// returned normally; myfn never ran; nothing was inserted

db.prepare('SELECT hex(zeroblob(300000000))').get();
// undefined - indistinguishable from "no row"

Utf8StringMaybeOneByte() now throws ERR_STRING_TOO_LONG when the
value exceeds String::kMaxLength, which covers both the UDF arguments
and the column reads that share it. The suppression in
THROW_ERR_SQLITE_ERROR() is gated on an actually pending exception so
it can no longer turn a failed statement into a success.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/sqlite

Copilot AI lite review requested due to automatic review settings September 22, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 Sep 22, 2026
@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.35%. Comparing base (191a3b2) to head (61fffa5).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66209      +/-   ##
==========================================
- Coverage   90.35%   90.35%   -0.01%     
==========================================
  Files         792      792              
  Lines      275434   275439       +5     
  Branches    52780    52790      +10     
==========================================
- Hits       248878   248861      -17     
- Misses      16981    16987       +6     
- Partials     9575     9591      +16     
Files with missing lines Coverage Δ
src/node_sqlite.cc 81.93% <80.00%> (-0.09%) ⬇️

... and 23 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.

@araujogui
araujogui requested a review from trivikr September 25, 2026 13:33
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 25, 2026
@trivikr trivikr removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 26, 2026
@trivikr

trivikr commented Sep 26, 2026

Copy link
Copy Markdown
Member

@araujogui The code change looks good. Can you please rebase?

@araujogui
araujogui force-pushed the sqlite-throw-on-oversized-strings branch from 1a27d49 to efad0d8 Compare September 28, 2026 13:40
@trivikr

trivikr commented Sep 28, 2026

Copy link
Copy Markdown
Member

The lint errors need fixing

/home/runner/work/node/node/test/parallel/test-sqlite-statement.js
Error:   1454:20  error  'DatabaseSync' is not defined  no-undef
Error:   1462:20  error  'DatabaseSync' is not defined  no-undef

SQLite serves TEXT up to SQLITE_MAX_LENGTH, past what V8 can represent
as a string. V8 returns an empty handle without throwing, and the
user-defined function path then suppressed the SQLite error as if a
JavaScript exception were pending. exec() reported success for a
statement that never ran, and get() returned undefined.

Throw ERR_STRING_TOO_LONG when the value cannot be converted, and
suppress a SQLite error only when an exception is actually pending.

Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
@araujogui
araujogui force-pushed the sqlite-throw-on-oversized-strings branch from efad0d8 to 61fffa5 Compare September 28, 2026 15:46
@araujogui araujogui added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 28, 2026
@trivikr trivikr added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 28, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 28, 2026
@nodejs-github-bot nodejs-github-bot added the lacks-second-approval Commit Queue PRs awaiting a second collaborator approval or completion of the required wait. label Sep 28, 2026
@nodejs-github-bot
nodejs-github-bot merged commit c5b7a06 into nodejs:main Sep 29, 2026
80 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in c5b7a06

@nodejs-github-bot nodejs-github-bot removed commit-queue PRs queued for automated landing through the Commit Queue. lacks-second-approval Commit Queue PRs awaiting a second collaborator approval or completion of the required wait. labels Sep 29, 2026
@araujogui
araujogui deleted the sqlite-throw-on-oversized-strings branch September 29, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants