Skip to content

test: Run the HTTP VFS tests for real, and make their errors fail the check - #832

Merged
krlmlr merged 1 commit into
mainfrom
claude/httpvfs-tests
Nov 27, 2026
Merged

krlmlr merged 1 commit into
mainfrom
claude/httpvfs-tests

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

The three tests in tests/testthat/test-httpvfs.R that start a local httpuv server have failed on every CI run, main included, while R CMD check reported Status: OK. The testthat summary in the logs reads [ FAIL 3 | ... ], but each test's cleanup then disconnected a fixture connection that was already closed, and testthat only counts a test as errored when the error is its last result (summarize_one_test_results()), so the "Already disconnected" warning recorded after the error hid it from test_check(); #837 tracks that trap. This came up on #829, where the maintainer asked for a fix from main that makes such errors fail loudly. This pull request makes those errors fail the check and makes the tests run for real against the HTTP VFS on main. The fixes for what they found are stacked on top of it, as listed below.

Masking. The fixture database is built and closed in its own scope (http_test_db()), and the remote connection's cleanup is registered with withr::defer() only once the connection has opened. An error therefore stays the last result of the test. With only this change, test_local(stop_on_failure = TRUE) on the old tests stops with "Test failures."

The tests themselves. The URL now carries the file: prefix (via http_vfs_uri() or sqliteRemote()); without it SQLite ignores vfs=http and opens a local file of that name. The server runs in a separate R process started with callr::r_bg() (local_http_server() in the new helper-httpvfs.R): the VFS performs blocking libcurl requests on the main R thread, so an httpuv app in the same process can never answer. The child gets the test's temporary directory as its TMPDIR, so the session directory it leaves behind when killed is removed with it, and it logs each request it receives. The test server answers HEAD without a body; httpuv otherwise sends the body for HEAD too, which corrupts the next response on the kept-alive connection and made some runs fail with libcurl's "HTTP/0.9 not allowed" error. The Range test compares the range_requests and bytes_fetched counters of sqliteHttpStats() with their values before the query, because they are process-wide, checks that the server sent less than the whole file, and pads the database so that the query reads only a fraction of it. The test for a server without Range support expects the "disk I/O error" that the open actually reports. The first test passes default.extensions = FALSE, since the default extensions cannot load over the HTTP VFS on main; #840 removes that. The tests skip with "HTTP VFS not compiled in (configure did not find libcurl)" when the VFS is not built, unless RSQLITE_TEST_HTTPVFS=true is set, in which case they fail; they also fail if the VFS is built but cannot be registered.

Until #842. These tests now make real transfers, and the HTTP VFS sets no libcurl timeout until #842, so a server that accepts a connection and never answers would hang the check; the test server answered in every run so far. Merge #832 through #842 together, or at least without a release in between.

CI coverage. No workflow installs libcurl headers for RSQLite on purpose, and DESCRIPTION declares no SystemRequirements for it. They arrive anyway: libcurl4-openssl-dev is the system requirement of the curl package, which the suggested packages gh, gert and rvest pull in, and macOS and Windows find libcurl on their own. The custom after-install step now sets RSQLITE_TEST_HTTPVFS=true, so losing libcurl on a runner fails the tests instead of skipping them. On this pull request, CI runs only the Linux smoke test, since the versions matrix is built for pull requests only from forks or cran-* branches; the full matrix (macOS, Windows, arm64, R 4.2 to devel) ran green on all 15 jobs, with the HTTP tests on each, at fa0b234, the last head of the earlier combined version of this pull request (run).

The stack. As the maintainer asked, the earlier combined version is split into scoped pull requests, each based on the one before:

  1. this one: the tests run for real;
  2. fix: Stop printing the response headers of every remote open over the HTTP VFS #839: stop printing the response headers of every remote open;
  3. fix: Load the default extensions on HTTP VFS connections #840: load the default extensions on HTTP VFS connections;
  4. fix: sqliteRemote() loads the default extensions #841: sqliteRemote() loads the default extensions;
  5. fix: Time out stalled HTTP VFS transfers #842: time out stalled transfers;
  6. fix: Let an interrupt abort an HTTP VFS transfer #843: let an interrupt abort a transfer.

The top of the stack has the same tree as fa0b234 merged with main, apart from a corrected sentence in ?sqliteHttpConfig. The problems found along the way that none of these fix are #834, #835, #836 and #837.

Reviews. Three clean reviews of the combined version (first, second, third) found no High issue, and their Medium and Low findings are fixed in the layers they concern. A clean review of the split found nothing above Low; its documentation finding is fixed in #842, the full check matrix on this branch is green on all 15 jobs (run), and what remains is under Accepted limitations.

https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE


Generated by Claude Code

krlmlr commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Review of this PR at 7d6d556, by a Claude Code reviewer with clean context that read the description, the diff and the parts of http.c, R/httpvfs.R and the vendored SQLite that the change relies on; built and installed this commit and its base (98d6d83); ran the HTTP VFS tests more than 45 times; ran devtools::test() and R CMD check --no-manual with NOT_CRAN=true; read the CI logs of this PR and of the latest scheduled run on main; and posted nothing itself. Line numbers refer to that commit. "Confirmed" means reproduced by running code.

Setup. Linux with R 4.5.3, libcurl 8.5.0, httpuv 1.6.17, callr 3.8.0, testthat 3.3.2 and withr 3.0.3. The environment sets HTTPS_PROXY but no http_proxy, and its no_proxy already lists 127.0.0.1, so ordinary runs never went near a proxy. To test the helper's own override, the file also ran with http_proxy, and separately all_proxy, pointing at a dead port and with no_proxy/NO_PROXY cleared; every expectation passed, so the override takes effect.

What was run. The HTTP tests ran 30 times in fresh processes, 15 times within one process and 3 times with the dead proxies, with test_local(load_package = "installed") against a private library: all 8 expectations passed every time, with no warnings, in 1.8 to 3.5 s per run. devtools::test() gave [ FAIL 0 | WARN 3 | SKIP 61 | PASS 10385 ] (the three warnings are the zh_TW locale ones in test-encoding.R). R CMD check --no-manual gave Status: 1 NOTE, the hidden .git of a git worktree; tests showed FAIL 0, and testthat.Rout contains no HTTP header lines. A first run under load failed the timing-sensitive "interrupt in busy handler" test (test-dbConnect.R:192); it passed on the rerun, and 3 of 3 times in isolation on both this commit and its base, so it is unrelated. R CMD check on this PR's tests with the base http.c gave Status: 1 ERROR, 1 NOTE, failing at test-httpvfs.R:19 with "Failed to load extension:".

What holds.

  • The masking is gone. On the base, the three server tests error with "unable to open database file", and each is still reported with error = FALSE because the "Already disconnected" warning comes after the error, so test_local(stop_on_failure = TRUE) returns normally; testthat 3.3.2's summarize_one_test_results() does look only at the last result. With this PR's tests, an error stops test_local() with "Test failures." and fails R CMD check. A scan of every test's results across the whole suite finds no error that a later result hides: 0 on this commit, 3 on the base.
  • Delegating xDl*() is safe, and the right pointer is passed. sqlite3LoadExtension() checks SQLITE_LoadExtension before it calls xDlOpen() (sqlite3.c#L144300); with loadable.extensions = FALSE on a remote connection, both SELECT load_extension(...) and the internal extension_load() still answer "not authorized" (Confirmed). load_extension() is SQLITE_DIRECTONLY, so a view in the remote database that calls it fails with "unsafe use of load_extension()" (Confirmed), and database content cannot use the newly working path. Passing the parent VFS pointer, as http.c#L123-L128 does, is the shim contract, and the unix and win32 methods ignore that argument in any case. Error text now reaches the user, and xDlClose() balances xDlOpen() when the connection closes.
  • Removing CURLOPT_HEADER does not affect parsing. libcurl hands every header line to CURLOPT_HEADERFUNCTION regardless; the option only also sends them to the write callback. The Range test can only read table t if xFileSize() returns the Content-Length from the HEAD response, since the Content-Range parser never fires. On the base, the HEAD headers appear in the test output; with this PR they do not (Confirmed).
  • The helper is sound on Linux. The child is killed when a test errors (checked with ps), a child that fails at start-up reports its own error through read_all_error(), the port file is written atomically with a rename, and cleanups run in the right order: disconnect, environment variables, server, temporary directory.
  • The description's claims hold, apart from the one in Medium 1. Without the file: prefix the open fails at the default VFS; an httpuv server in the same process never answers; without the HEAD branch, 5 of 15 runs errored; the base's 8,192-byte database is smaller than the 32-byte probe plus two 4,096-byte pages; the no-Range open fails with "disk I/O error"; a server without Range support makes the VFS download the whole file three times (24,576 bytes for an 8,192-byte file); the scheduled run 42782056535 on main logs "Found libcurl" and [ FAIL 3 | on macOS, Windows and Ubuntu jobs and FAIL 0 in "Without httpuv"; and src/ext-http.dd does not list vendor/extensions/http.c (all Confirmed).

High

None.

Medium

1. The description says this PR's CI is the helper's first run outside Linux, but CI on this PR ran only the Linux smoke test; the macOS and Windows jobs were skipped. By reading the check runs of 7d6d556 and the workflow: for a pull_request event, the versions matrix is built only for a fork or a cran-* branch (.github/workflows/R-CMD-check.yaml#L165), so the only check job is "Smoke test: stock R" on Ubuntu. The new helper is the part most likely to behave differently across platforms (a callr child stopped with kill(), a port file renamed into place, no_proxy set at run time), and its first macOS and Windows runs would be the nightly on main after the merge. Suggested fix: run the matrix on this branch before merging with a workflow_dispatch of R-CMD-check.yaml with versions-matrix=true, and correct that sentence in the description.

2. The VFS sets no libcurl timeouts, and this PR is what makes CI depend on its transfers, so a server that stops answering blocks R CMD check until the job's 120-minute timeout. Confirmed: with an httpuv server in the same process, which cannot answer while the VFS blocks the main thread, dbConnect(SQLite(), "file:http://127.0.0.1:<port>/db.sqlite?vfs=http&immutable=1", flags = SQLITE_RO, default.extensions = FALSE) did not return until timeout 25 killed R. None of the three transfers sets CURLOPT_CONNECTTIMEOUT, CURLOPT_TIMEOUT or CURLOPT_LOW_SPEED_* (httpDownload(), http_probe_meta(), http_fetch_range()), and no progress callback checks for an R interrupt. Before this PR the tests failed at open and never reached the network; now any stall in the test server hangs the job, and a local devtools::test() hangs indefinitely. Suggested fix: set CURLOPT_CONNECTTIMEOUT (for example 30 s) and CURLOPT_LOW_SPEED_LIMIT = 1 with CURLOPT_LOW_SPEED_TIME = 60 where each handle is created, adjustable through an environment variable, so that a stall becomes SQLITE_IOERR, and add a test with a server that accepts and never answers.

Low

3. expect_identical(stats$full_download, before$full_download) cannot fail when the file runs in order. Confirmed: full_download is a sticky flag, and the first server test always does a full download, so before at test-httpvfs.R#L46 is already TRUE and #L59 compares TRUE with TRUE. The check that would catch a full download is expect_lt(server$bytes_sent(), length(body)) at L54. Suggested fix: drop L59, or compare counts.

4. Each killed server child leaves its empty RtmpXXXXXX session directory behind, three per run of the file. Confirmed. kill() sends SIGKILL, so the child R never cleans up (helper-httpvfs.R#L38-L43). R CMD check's detritus check exempts Rtmp* directories, so it raises no NOTE, but developers' temporary directories fill up. Suggested fix: pass env = c(callr::rcmd_safe_env(), TMPDIR = dir) to callr::r_bg(), so the child's session directory lands inside the withr temporary directory, which is removed after the kill.

5. sqliteRemote() still hard-codes default.extensions = FALSE, the workaround for the bug this PR fixes, so its connections lack the default extension and callers cannot opt in. Confirmed on a remote database: sqliteRemote(url) followed by SELECT stdev(x) FROM t fails with "no such function: stdev", while dbConnect(SQLite(), http_vfs_uri(url), flags = SQLITE_RO) on the same file succeeds, and sqliteRemote(url, default.extensions = TRUE) fails with 'formal argument "default.extensions" matched by multiple actual arguments'. The argument at R/httpvfs.R#L56 came in with #680 through a commit titled "Fix sqlite_remote: don't load default extensions". Suggested fix: drop it, so that sqliteRemote() gets dbConnect()'s default, or leave it for a follow-up.

6. If libcurl stops arriving on a runner, these tests turn into a silent skip. By reading: helper-httpvfs.R#L3-L6 skips when the VFS is not compiled in, and CI gets libcurl only as a system requirement of curl, which gh, gert and rvest pull in. Suggested fix: fail instead of skipping when an opt-in variable is set, and set it in CI, or install libcurl explicitly in .github/workflows/custom/before-install.

7. testthat still hides an error that is followed by any other result, so the trap remains for future tests. The scan above is Confirmed; the rest is by reading the testthat 3.3.2 source. This PR removes the trigger in test-httpvfs.R, and no test in the suite is affected today, but any cleanup elsewhere that warns after an error would hide that error again from test_check() (tests/testthat.R#L12), while the summary line still counts it. Suggested fix: report it to testthat; until then, the shared workflow could fail when the final [ FAIL n | line in testthat.Rout is not FAIL 0.


Generated by Claude Code

krlmlr commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by this comment.

The clean review of 7d6d5563 found no High issue, two Medium and five Low ones. Being fixed: libcurl timeouts, so a stalled server cannot hang R CMD check (Medium 2); the vacuous full_download check; the Rtmp* directories of killed server children; the default.extensions = FALSE workaround in sqliteRemote(); and a silent skip if libcurl stops arriving on a runner. The macOS and Windows jobs will run on this branch through a manual dispatch of the check matrix once the fixes are in (Medium 1). This list will be posted again after that. This remains:

  • tests/testthat.R#L12: testthat counts a test as errored only when the error is its last result, so a cleanup anywhere else that warns after an error would hide that error from test_check() again, while the summary line still reads [ FAIL n | .... This pull request removes the trigger in test-httpvfs.R, and a scan of the whole suite finds no other hidden error (3 on the base, 0 here), but nothing guards against it coming back; that is for testthat or the shared CI. Relevance: low; reviewer's confidence: high (scan confirmed, hazard by reading).

Generated by Claude Code

krlmlr commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Review of the fixes at 4beb1b3 (the three commits after 7d6d556), by a Claude Code reviewer with clean context that read the pull request description, the first review and the "Accepted limitations" comment, the diff 7d6d5563..4beb1b37, and the parts of http.c, the vendored SQLite pager, the workflows and the shared cynkratemplate actions that the change relies on; built and installed this commit and 7d6d556 into private libraries; ran the HTTP VFS tests 25 times, and devtools::test() and R CMD check --no-manual with NOT_CRAN=true; tested the timeouts, the interrupt and the probe against scripted servers; read the logs of the dispatched matrix run 42858776332; and posted nothing itself. Line numbers refer to 4beb1b3. "Confirmed" means reproduced by running code.

Setup. Linux with R 4.5.3, libcurl 8.5.0 (threaded resolver), httpuv 1.6.17, callr 3.8.0 and testthat 3.3.2. As in the first review, the environment sets only https_proxy, and no_proxy lists 127.0.0.1, so the plain-HTTP tests never reach a proxy. Besides the package's own tests, a small scripted server logged every request while serving the same database with deliberate faults: never answer, never answer HEAD, send one byte every two seconds, answer 503 to or reset the first requests, or stall one chosen request; a listening socket whose accept queue was full stood in for a host that never completes a connection.

What was run. The three httpvfs test files 15 times in fresh processes (41 expectations, 4.4 to 5.0 s per run) and test-httpvfs.R 10 times within one process (the stall test took 1.53 to 1.83 s each time), with no failure or warning. devtools::test(): [ FAIL 0 | WARN 3 | SKIP 61 | PASS 10387 ] (the zh_TW locale warnings). R CMD check --no-manual: Status: 1 NOTE, the hidden .git of the worktree; "checking compiled code ... OK", since R_ToplevelExec() and R_CheckUserInterrupt() are API. CI run 42858776332 at 4beb1b3: all 15 check jobs succeeded. macOS (R 4.5 and 4.6): Status: OK, [ FAIL 0 | WARN 0 | SKIP 61 | PASS 10390 ]; Windows (windows-latest devel, 4.5, 4.6, and windows-11-arm 4.6): Status: OK, [ FAIL 0 | WARN 0 | SKIP 62 | PASS 10386 ]; every one logs "Found libcurl" and RSQLITE_TEST_HTTPVFS=true, none skips an HTTP test, and the stall test took 1.55 to 1.74 s. The eight Linux jobs (R 4.2 to devel on amd64, plus arm64 4.6 and devel) and the smoke test also report Status: OK and FAIL 0.

What holds.

  • The first review's findings are dealt with. Medium 1: the matrix ran and is green on macOS and Windows. Medium 2: the timeouts work (below). Low 3: the vacuous full_download check is gone. Low 4: after a run with TMPDIR pointing at an empty directory, the directory is empty again (Confirmed). Low 5: sqliteRemote() loads the default extensions, and sqliteRemote(url, default.extensions = FALSE) is now accepted (Confirmed). Low 6: with RSQLITE_TEST_HTTPVFS=true and a mocked missing VFS, the helper stops; unset, TRUE or 1 skip (Confirmed). Low 7 remains accepted.
  • The timeouts behave as documented for ordinary values (Confirmed). Against a server that never answers, RSQLITE_HTTP_STALL_TIMEOUT=2 fails the open in 2.07 s after one request (the HEAD), the default in 60.1 s; against the full accept queue, RSQLITE_HTTP_CONNECT_TIMEOUT=2 fails in 2.02 s, the default in 30.0 s; a trickle of 0.5 bytes per second is aborted; a stall during a query after a successful open reports "disk I/O error". CURLOPT_NOPROGRESS is set to 0 after CURLOPT_XFERINFOFUNCTION (http.c#L100-L101).
  • An interrupt aborts cleanly (Confirmed). In a callr session, interrupting sqliteRemote() returns at once with an R error against a server that never answers, a host whose connection never completes, and a query whose page request never gets an answer; the same connection then runs another query, stdev() included. The interrupt surfaces as an ordinary error, as ?sqliteHttpConfig now says and as the R busy handler already does.
  • Calling R from the callback is safe on the paths that exist. libcurl calls the transfer-info callback on the thread that called curl_easy_perform(), which is the thread that called sqlite3_step(), which is R's thread; RSQLite never calls SQLite from another thread, and SQLite's sorter threads never fetch pages of the main database (by reading). R_ToplevelExec() clears the handler and restart stacks, so the interrupt's longjmp stops inside the callback. R code can still run inside the callback (options(error = ), R_ProcessEvents()), as with the R busy handler.
  • The probe state is reset correctly, and losing the old retry is an improvement (Confirmed). probe_rc lives in HttpFile, which httpOpen() zeroes. An open against a server that answers 500 sent four requests at 7d6d556 and two here, against a silent server one. A transient failure can now fail an open that used to succeed (a server that answers 503 to, or resets, its first two requests), but the old success was broken: for an immutable file SQLite takes the size from that first xFileSize() call only, so the old connection saw an empty database and SELECT count(*) FROM t failed with "no such table: t". A server that never answers HEAD but answers GET now fails after the stall timeout, where it used to hang forever.
  • No workflow that calls the after-install action runs without libcurl. Callers are R-CMD-check.yaml (smoke, full matrix, "Without …"), R-CMD-check-dev.yaml (base and dev) and pkgdown.yaml (no tests). The Ubuntu jobs get libcurl4-openssl-dev through curl, and the "Without …" jobs keep it; "Without httpuv" still skips, since the helper checks the VFS before httpuv; rhub.yaml does not call the action.

High

None.

Medium

None.

Low

1. No test triggers an interrupt, so the abort path is untested on every platform. The matrix shows that the callback in http.c#L80-L88 compiles, links and returns 0 on macOS and Windows; nothing makes it return 1. Suggested fix: a test modeled on the busy-handler one, interrupting a callr::r_session that opens a server that never answers and expecting "unable to open database file" within seconds; such a test passed 5 times out of 5 against this commit in about 1.7 s and fails against 7d6d556 (Confirmed).

2. The stall test passes just as well when nothing is listening. Confirmed: sqliteRemote("http://127.0.0.1:1/db.sqlite") fails with the same "unable to open database file" in 0.03 s, so test-httpvfs.R#L81-L93 cannot tell a stall timeout from a refused connection or a server that died after writing its port file. Suggested fix: log each request in the test server (helper-httpvfs.R#L88-L91), expose the count, and expect exactly one request in the stall test, which also pins the claim that a HEAD that times out skips the GET.

3. The new variables quietly turn odd values into something else. http_env_int64() maps 0, negative and non-numeric values to the default, and the result is cast to long unchecked (http.c#L97-L99). Confirmed: RSQLITE_HTTP_STALL_TIMEOUT set to 0, -3 or abc aborts after 60 s, 2.9 after 2 s; RSQLITE_HTTP_CONNECT_TIMEOUT set to 0 or abc gives 30 s; libcurl 8.5.0 rejects a connect timeout above 2147483 with CURLE_BAD_FUNCTION_ARGUMENT, whose return value is ignored, so the connect timeout becomes libcurl's own 300 s. By reading: on Windows long has 32 bits, so a stall value of 4294967296 becomes 0, which disables the stall check. None of this is documented in R/httpvfs_config.R#L16-L20. Suggested fix: clamp to 1 to 2147483 before the cast and document that only positive whole seconds are honored, or let 0 disable the stall check.

4. CURLOPT_XFERINFOFUNCTION needs libcurl 7.32.0 (August 2013) or later, and configure checks no version. By reading. Where configure finds an older libcurl, for example 7.29.0 on CentOS/RHEL 7, the package now fails to compile (http.c#L100), where it used to build with the VFS. Suggested fix: guard the two lines with #if LIBCURL_VERSION_NUM >= 0x072000 and fall back to CURLOPT_PROGRESSFUNCTION or to no callback, or have configure disable the VFS below that version.

5. Pre-existing: a HEAD that fails with an HTTP status or a reset leaves the size unknown, and the open succeeds on an empty database. Confirmed at both commits: with a server that answers the HEAD with 503, or resets it, and serves the GETs normally, sqliteRemote() opens and SELECT count(*) FROM t fails with "no such table: t". Only a successful HEAD sets the content length (http.c#L269-L272), the Content-Range fallback never fires (already listed for follow-up), and httpFileSize() then reports 0 bytes. By reading, a presigned S3 GET URL, which answers HEAD with 403, would hit this. Suggested fix, for that follow-up: take the total from the Content-Range of the first ranged GET once the parser is fixed, and fail the open if the size is still unknown.


Generated by Claude Code

krlmlr commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by this comment.

The first clean review found two Medium and five Low issues; both Medium and four Low ones are fixed up to 4beb1b3, which the second clean review confirmed without High or Medium findings, and the full check matrix on this branch (run 42858776332) is green on all 15 jobs, macOS and Windows included. Four of the second review's Low findings are fixed in 2dde544 and 2d62a02: a test of the interrupt, a request count in the stall test, clamped timeout values, and a fallback for libcurl older than 7.32.0; the request count proves the HEAD reached a live server, but cannot show that the GET is skipped after it times out, since the test server stops reading requests while it stalls. These remain:

  • tests/testthat.R#L12: testthat counts a test as errored only when the error is its last result, so a cleanup anywhere else that warns after an error would hide that error from test_check() again, while the summary line still reads [ FAIL n | .... This pull request removes the trigger in test-httpvfs.R, and a scan of the whole suite finds no other hidden error (3 on the base, 0 here), but nothing guards against it coming back; that is for testthat or the shared CI. Relevance: low; reviewer's confidence: high (scan confirmed, hazard by reading).
  • src/vendor/extensions/http.c#L269-L272: pre-existing, not introduced here: when the HEAD request fails with an HTTP status or a reset while GETs work, the size of the file stays unknown, httpFileSize() reports 0 bytes, and the open succeeds on what SQLite sees as an empty database (SELECT count(*) FROM t fails with "no such table: t"); a presigned S3 GET URL, which answers HEAD with 403, would hit this. It belongs with the follow-ups this pull request lists, together with the Content-Range parser that never fires. Relevance: medium; reviewer's confidence: high.

Generated by Claude Code

krlmlr commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Review of the fixes at 2d62a02 (the two commits after 4beb1b3), by a Claude Code reviewer with clean context that read the pull request description, the second review and the "Accepted limitations" comment, the diff 4beb1b37..2d62a027 and the parts of http.c around it, and the option handling in libcurl's setopt.c and speedcheck.c from 7.29.0 to 8.23.0; installed 2d62a02 into a private library on R_LIBS and ran the HTTP VFS tests 16 times against it, plus R CMD check --no-manual, both with NOT_CRAN=true; compiled ext-http.c with GCC and Clang against the libcurl headers of 7.29.0, 8.5.0 and 8.23.0; drove the failure paths of http_easy_init() and of the interrupt test with an LD_PRELOAD shim around libcurl; read the jobs of the dispatched matrix run 42866213223; and posted nothing itself. Line numbers refer to 2d62a02. "Confirmed" means reproduced by running code.

What was run. The three httpvfs test files 16 times in fresh processes against the installed build: all 47 expectations passed every time, with no warning or skip, the stall test in 1.58 to 1.78 s and the interrupt test in 1.56 to 1.85 s, no R or callr process left behind, and an empty TMPDIR left empty. R CMD check --no-manual: Status: 1 NOTE (the worktree's .git), "checking compiled code ... OK", tests [ FAIL 0 | WARN 3 | SKIP 61 | PASS 10393 ], six expectations more than at 4beb1b3. CI run 42866213223: the smoke test and all 14 matrix jobs green; macOS (R 4.5 and 4.6) [ FAIL 0 | WARN 0 | SKIP 61 | PASS 10396 ], Windows (windows-latest devel, 4.5 and 4.6, windows-11-arm 4.6) [ FAIL 0 | WARN 0 | SKIP 62 | PASS 10392 ], each reporting test-httpvfs.R:121 to :127 as successes; the per-expectation timestamps show the session coming back after the interrupt in 0.39 to 0.51 s on Windows and 10 to 20 ms on macOS.

What holds.

  • Low findings 1 to 4 of the second review are dealt with. The new test makes the callback return 1: with a shim that swallows CURLOPT_XFERINFOFUNCTION, it fails with "timeout" against "ready" and still leaves no process behind (Confirmed). The stall test requires exactly one logged HEAD, which a refused connection or a dead server cannot produce.
  • http_env_seconds() parses strictly and safely (Confirmed with the function compiled verbatim into a test program). Unset, empty or blank values, 0, -0, -5, 2.9, 1e3, 0x10, 5abc, ++5, a trailing space or newline, and a negative overflow give the default; 5, +5, 00012 and values with leading whitespace give the number; 2147484, 9223372036854775808 and larger give 2147483. The comparison happens in long long and the result fits a 32-bit long, so Windows is safe; 2147483 is INT_MAX/1000, the limit libcurl 7.61 to 8.18 accept for CURLOPT_CONNECTTIMEOUT, and times 1000 it still fits the 32-bit long that older libcurl multiplies low_speed_time by. Every value, extremes included, still opens a database and answers a query.
  • http_easy_init() fails cleanly (Confirmed with a shim that fails one curl_easy_setopt() and counts handles): each time the open fails, that handle sends no request, and every handle created is cleaned up. All three callers check for NULL (httpDownload(), the probe, http_fetch_range()), and httpClose() cleans up only a non-NULL handle.
  • The fallback for libcurl before 7.32.0 is right (Confirmed by compiling). 0x072000 is 7.32.0, the release that added CURLOPT_XFERINFOFUNCTION; GCC and Clang compile ext-http.c with the 7.29 headers at -O2 -Wall -Wextra -pedantic without a new warning, and curl's typecheck-gcc.h accepts the double callback for CURLOPT_PROGRESSFUNCTION; with the 8.5.0 and 8.23.0 headers and -Werror=deprecated-declarations, the deprecated option is never compiled. Not tried: linking against a real 7.29 library.
  • The request log has no race in practice (Confirmed): the server writes the line within 16 ms of a request arriving, and the stall test reads it more than a second later; the file sits in the test's own temporary directory, which withr removes after killing the server.

High

None.

Medium

None.

Low

1. The interrupt test assumes the session reaches the transfer within one second. Confirmed. Here the session needs 0.45 to 0.51 s from session$call() until the HEAD reaches the server, mostly to load RSQLite and its imports, and the test interrupts after poll_process(1000) (test-httpvfs.R#L121-L122). An interrupt that arrives before the transfer is an ordinary R interrupt, which tryCatch(error = ) does not catch: with the interrupt at 150 ms instead, session$read() returns result = NULL with a "callr subprocess interrupted" error, and the test fails. Suggested fix: load the package in the session first, wait for the request log to show the HEAD before interrupting, check out$error before out$result, and pin RSQLITE_HTTP_STALL_TIMEOUT before starting the session.

2. The interrupt test fails instead of skipping when the session cannot use the package under test. Confirmed: with RSQLite loaded from a library that is not on .libPaths(), as under devtools::test() without an installed copy, the session fails at once with "there is no package called 'RSQLite'". skip_if_no_http_vfs() checks the package under test, not the installed one the session uses. The busy-handler test has the same dependency; R CMD check and CI are not affected. Suggested fix: skip when the session's namespace path differs from the tests' own.

3. A handle whose options cannot be set fails the open with "SQL logic error". Confirmed with the shim. When it has no handle, the probe, httpDownload() and http_fetch_range() return SQLITE_ERROR. The behavior is right and nothing leaks; only the message does not point at the transfer, unlike the "unable to open database file" that every other failed probe gives. Suggested fix: return SQLITE_CANTOPEN from the probe and httpDownload(), and SQLITE_IOERR from http_fetch_range().

4. The documentation of the timeout values does not quite match the code. R/httpvfs_config.R#L20-L21 says that "anything else uses the default", but a larger value is capped at 2147483 (Confirmed); libcurl 8.19.0 and later cap CURLOPT_LOW_SPEED_TIME at 65535 s, so the C comment at http.c#L80-L81 no longer holds for that option (by reading); and Sys.setenv(RSQLITE_HTTP_STALL_TIMEOUT = 1e5) stores 1e+05, which the strict parser silently treats as the default (Confirmed). Suggested fix: document the caps and that values must be digits, or accept whole numbers in any notation.


Generated by Claude Code

krlmlr commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by this comment.

The first clean review found two Medium and five Low issues, the second and the third none above Low. All of their Low findings are fixed up to fa0b234, except the two below; the request count of the stall test proves the HEAD reached a live server, but cannot show that the GET is skipped after it times out, since the test server stops reading requests while it stalls. The full check matrix on this branch was green on all 15 jobs, macOS and Windows included, at 4beb1b3, at 2d62a02 and at fa0b234. These remain:

  • tests/testthat.R#L12: testthat counts a test as errored only when the error is its last result, so a cleanup anywhere else that warns after an error would hide that error from test_check() again, while the summary line still reads [ FAIL n | .... This pull request removes the trigger in test-httpvfs.R, and a scan of the whole suite finds no other hidden error (3 on the base, 0 here), but nothing guards against it coming back; that is for testthat or the shared CI. Relevance: low; reviewer's confidence: high (scan confirmed, hazard by reading).
  • src/vendor/extensions/http.c#L269-L272: pre-existing, not introduced here: when the HEAD request fails with an HTTP status or a reset while GETs work, the size of the file stays unknown, httpFileSize() reports 0 bytes, and the open succeeds on what SQLite sees as an empty database (SELECT count(*) FROM t fails with "no such table: t"); a presigned S3 GET URL, which answers HEAD with 403, would hit this. It belongs with the follow-ups this pull request lists, together with the Content-Range parser that never fires. Relevance: medium; reviewer's confidence: high.

Generated by Claude Code

@krlmlr

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Split the PR. Scoped follow-up PRs and issues for the discovered problems.

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

CI note for the whole stack: the smoke test of #832, #839, #840, #841, #842 and #843 failed before any R code ran. The shared install step could not resolve the Ubuntu package mirrors (Temporary failure resolving 'security.ubuntu.com', and the same for archive.ubuntu.com and azure.archive.ubuntu.com) while installing aspell, and stopped with exit code 100. That is the runners' network, not these changes, and there is no fix to port; a re-run of this pull request's job at 14:01 UTC failed the same way. The jobs of the other five will be re-run once the mirrors resolve again, and the fixes from the clean review of the split will trigger new runs on every layer.


Generated by Claude Code

krlmlr commented Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by this comment.

The first clean review found two Medium and five Low issues, the second and the third none above Low. All of their Low findings are fixed up to fa0b234, except the two below; the request count of the stall test proves the HEAD reached a live server, but cannot show that the GET is skipped after it times out, since the test server stops reading requests while it stalls. The full check matrix on this branch was green on all 15 jobs, macOS and Windows included, at 4beb1b3, at 2d62a02 and at fa0b234. These remain:

  • tests/testthat.R#L12: testthat counts a test as errored only when the error is its last result, so a cleanup anywhere else that warns after an error would hide that error from test_check() again, while the summary line still reads [ FAIL n | .... This pull request removes the trigger in test-httpvfs.R, and a scan of the whole suite finds no other hidden error (3 on the base, 0 here), but nothing guards against it coming back; that is for testthat or the shared CI. Relevance: low; reviewer's confidence: high (scan confirmed, hazard by reading).
  • src/vendor/extensions/http.c#L269-L272: pre-existing, not introduced here: when the HEAD request fails with an HTTP status or a reset while GETs work, the size of the file stays unknown, httpFileSize() reports 0 bytes, and the open succeeds on what SQLite sees as an empty database (SELECT count(*) FROM t fails with "no such table: t"); a presigned S3 GET URL, which answers HEAD with 403, would hit this. It belongs with the follow-ups this pull request lists, together with the Content-Range parser that never fires. Relevance: medium; reviewer's confidence: high.

Generated by Claude Code

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Review of the split stack #832 → #839 → #840 → #841 → #842 → #843 at heads 7ff6e79, 6b8bc7d, a8a25db, 98af1cb, b9e1533 and 6514b4f, by a Claude Code reviewer with clean context that read the six descriptions and commit messages, the three earlier clean reviews and the "Accepted limitations" comment on #832, each layer's diff, and the parts of http.c, R/httpvfs*.R, the workflows and libcurl's setopt.c (8.18.0 and 8.19.0) that the changes rely on; built each layer and main (3b7bea3) with R CMD build and installed each into its own library; ran each layer's full test suite against its own installed copy with NOT_CRAN=true, RSQLITE_TEST_HTTPVFS=true and R_LIBS pointing at that library, counting every result of every test with a ListReporter; ran each fix's tests against the layer below it; regenerated the documentation of every layer with roxygen2; ran R CMD check --no-manual on the bottom and the top; tried the open path against scripted servers; and posted nothing itself. Setup: Linux, R 4.5.3, libcurl 8.5.0, httpuv 1.6.17, callr 3.8.0, testthat 3.3.2, withr 3.0.3, roxygen2 8.1.1.9000. "Confirmed" means reproduced by running code.

What was run.

What holds.

High

None.

Medium

None.

Low

1. Until #842 merges, the HTTP tests that #832 turns on make network transfers with no libcurl timeout, so a stalled server would hang R CMD check at every layer from #832 to #841. Confirmed: against a server that accepts a connection and never answers, sqliteRemote() with #841 installed was still blocked after 45 s, when timeout killed R; with #842 installed, it fails in 1.04 s. On main these tests never reach the network, because they open a local file of that name. From #832 on, they open real connections (test-httpvfs.R#L19) through handles created without limits (http.c#L216), and a push to main runs them on the full matrix. This is the first review's Medium 2: the combined version fixed it, and the split moves the fix four layers up. The test server has answered reliably in every run so far, so the practical risk is small, but no description from #832 to #841 mentions it. Suggested fix: say in #832's description that the tests run without timeouts until #842, and merge #832 through #842 together, or at least without a release in between.

2. No layer below the top has a CI run of its own tree, and the matrix result the descriptions cite covers only the top. By reading the check runs: the smoke test failed on all six heads before any R code ran, and a pull request from a non-fork branch never builds the matrix (R-CMD-check.yaml#L165). The matrix last ran at fa0b234, whose tree differs from #832 to #842 (timeouts, no header output, the first test loading the default extensions). #832 is the layer that turns the HTTP tests on for every platform once it merges, yet its own tree has run on no platform. Suggested fix: once the mirrors resolve, re-run the smoke tests and dispatch R-CMD-check.yaml with versions-matrix=true on claude/httpvfs-tests before merging it; the layers above can rely on their smoke tests plus the matrix run of the top.

3. ?sqliteHttpConfig says the values are read on the first open in the process, but the two timeout variables that #842 documents there are read at every open. Confirmed at #842: in one R process, an open against a silent server failed after 3.02 s with RSQLITE_HTTP_STALL_TIMEOUT=3, then after 1.00 s with 1; the stall test itself depends on this, since it sets the variable after earlier tests have opened remote databases. The sentence (R/httpvfs_config.R#L7) is older than the stack, and by reading, the three existing variables are also read per open, in httpOpen() and the probe, but #842 adds two more variables under it. Suggested fix: in #842, change the sentence to "These values are read each time a remote database is opened." and regenerate man/sqliteHttpConfig.Rd.

4. #832 adds the request log and requests(), but nothing uses them until #842. Confirmed: no test-httpvfs.R calls requests() before #842 (helper-httpvfs.R#L80-L85). It is harmless, and #832's description mentions the log, but a reviewer of #832 reads test infrastructure that only #842's stall test needs. Suggested fix: move the request log to #842 together with answer, or accept.

5. #839 has no regression test, although the stack already runs the package in a second process. By reading: the description says the headers go to C-level stdout, which only a second process could capture; #843's local_rsqlite_session() provides that process, and the header output is plain to see in a captured run (3 blocks at #832, none at #839, Confirmed). Suggested fix: in a follow-up, open a remote database in such a session and expect its stdout to have no HTTP/1.1 line, or accept, since the fix removes one option.


Generated by Claude Code

krlmlr commented Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

Accepted limitations

The clean review of the split found nothing above Low. Its finding 3 is fixed in #842 and carried into #843; its finding 2, a CI run of this layer's own tree, is done: the full check matrix on this branch, macOS, Windows and arm64 included, is green on all 15 jobs (run); its finding 5 concerns #839. These remain here, together with what the reviews of the combined version left:


Generated by Claude Code

… check

The three tests in `test-httpvfs.R` that start a local server failed on every CI run,
yet `R CMD check` passed.
Each test's cleanup disconnected a fixture connection that was already closed,
and testthat counts a test as errored only when the error is its last result,
so the "Already disconnected" warning that followed hid the error.
The fixture database is now built and closed in its own scope, `http_test_db()`,
and the remote connection's cleanup is registered with `withr::defer()` only once it has opened,
so an error stays the last result and fails the check.

The URL now carries the `file:` prefix, through `http_vfs_uri()` or `sqliteRemote()`,
without which SQLite ignores `vfs=http` and opens a local file of that name.
The server runs in a separate process started with `callr::r_bg()`, by `local_http_server()` in the new `helper-httpvfs.R`,
because the VFS blocks the R process while it waits for a response,
so an httpuv server in the same process never answers.
The server gets the test's temporary directory as its `TMPDIR`,
so the session directory it leaves behind when killed is removed with it,
and it logs the bytes it sends and the method of each request it receives.
It answers HEAD requests without a body,
which httpuv would otherwise send and so corrupt the next response on the kept-alive connection.

The Range test compares the process-wide counters of `sqliteHttpStats()` with their values before the query,
checks that the server sent less than the whole file,
and pads the database so that the query reads only a fraction of it.
The test for a server without Range support expects the "disk I/O error" that the open reports.
The HTTP VFS cannot load the default extensions yet,
so the test that opens the database with `dbConnect()` passes `default.extensions = FALSE`.

The tests skip with a reason when the HTTP VFS is not compiled in,
and fail instead when `RSQLITE_TEST_HTTPVFS=true` is set,
which the custom after-install step of CI now does, so that losing libcurl on a runner is noticed.
They also fail when the VFS is compiled in but cannot be registered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants