Просмотр исходного кода

build: 0.10.0, and fix an overload GCC rejects where clang did not

A braced list passed to imapUidFetch is viable for BOTH overloads, and
the two readings are different commands: `{7, 9}` is either the set
`7,9` or the single range `7:9`, and `{uid}` is either one uid or the
range `uid:0`. clang silently picks one, GCC refuses the call as
ambiguous.

So the entire mail surface compiled cleanly on the dev host for days and
then failed the first release build that ever saw it. The call sites now
name the vector type, and the declaration says why.

Worth recording beyond this one call: host-build.sh passing is not
evidence that the .deb will build, because it is a different compiler.
A feature is not finished until the Docker path has compiled it.

0.10.0, not a reuse of 0.9.2: that version is already published to the
apt repo with content that contains no mail at all - the debs were built
at 14:33 and the first mail commit landed at 15:45 - and a published
version number is never reused for different content.

Carries ctx.mail, the framing-padded literal fix, the binary /fn request
body, and the per-project network egress switch.

Verified in the built packages rather than assumed: the runner deb
contains ctx.mail, BODY.PEEK, mail_protocol_error and network_egress,
links libcurl/8.22.0-DEV, and has no HTTP support compiled in.

1189/1189 green.
fszontagh 1 месяц назад
Родитель
Сommit
b6015209a8
5 измененных файлов с 12 добавлено и 4 удалено
  1. 1 0
      CLAUDE.md
  2. 1 1
      VERSION
  3. 2 2
      runner/src/host_context.cpp
  4. 7 0
      runner/src/net/imap_commands.hpp
  5. 1 1
      runner/tests/host_context_test.cpp

+ 1 - 0
CLAUDE.md

@@ -137,6 +137,7 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **QuickJS is pinned to an exact quickjs-ng tag** (`SVAPI_QUICKJS_TAG`, `runner/CMakeLists.txt`). QuickJS bytecode carries **no version stamp**, so a silent upgrade makes a cached blob *misread* rather than fail. quickjs-ng, not Bellard's tree: the module/promise/stack entry points the core needs (`JS_GetModuleNamespace`, `JS_PromiseState`, `JS_SetMaxStackSize`, `JS_IsJobPending`) are public API there. `JsBytecode` is an in-process cache only - never persist it without a QuickJS build fingerprint.
 - **QuickJS's job queue belongs to the `JSRuntime`, not the `JSContext`.** A fresh context per run is therefore *not* enough to isolate tenants: a run that times out mid-microtask leaves its jobs queued, and they would execute inside the next tenant's run. The core flushes them with the deadline forced into the past and marks the runtime `poisoned()` if anything survives; the pool destroys a poisoned runtime instead of leasing it out. An OOM poisons it too.
 - **`/etc/smartbotic-vectorapi` must stay mode 0751, not 0750.** The runner runs as its own user and needs `+x` to traverse the directory to `runner.json`; it still cannot list it, and the server's `0640` files stay unreadable to it. Both `server.postinst` and `runner.postinst` set it, and a server upgrade resetting it to `0750` breaks the runner on its **next restart** - a failure that surfaces weeks later with no obvious cause.
+- **The dev host's clang and the release GCC disagree about overload ambiguity, and the release toolchain is the only one that counts.** A braced list passed to `imapUidFetch` is viable for BOTH overloads - `{7, 9}` is either the set `7,9` or the single range `7:9`, and `{uid}` is either one uid or the range `uid:0` - so the two readings are DIFFERENT COMMANDS. clang silently picks one, GCC refuses the call, and the whole mail surface therefore compiled cleanly on the host for days and then failed the first release build it ever saw. Call such an overload set with an explicit vector type. The lesson is bigger than the call: `scripts/host-build.sh` passing is not evidence that the `.deb` will build, so a feature is not finished until the Docker path has compiled it.
 - **The deb `Depends` lists are HAND-MAINTAINED** - `create-debs.sh` copies each `control.*` template verbatim and never runs `dpkg-shlibdeps`, so a new shared-library dependency does **not** appear by itself; it surfaces as a service that refuses to start on a customer box. The mail surface added two to `control.runner`, both confirmed with `ldd` against the built binary rather than guessed: **`ca-certificates`**, because the vendored curl detects the CA bundle at CONFIGURE time and bakes the path in, and with TLS verification always on a missing bundle makes *every* mail connection fail as `mail_tls_untrusted` (which reads as a broken mail server, not a missing package); and **`libidn2-0`**, because the vendored curl keeps IDN support. IDN is deliberately not compiled out - mail hostnames are usually ASCII, but breaking an internationalised one to save a dependency is the wrong trade. **zlib, zstd and brotli are deliberately absent**: they are HTTP content encodings, HTTP is compiled out of the vendored curl, and leaving them enabled made them real package dependencies for capabilities the code cannot reach.
 - **Installing the runner does not enable functions.** `config.json` ships with no `functions.runners` endpoints, and the server disables the function routes when the list is empty (answering 503). An operator has to add the endpoint by hand, and set the same `SVAPI_RUNNER_TOKEN` in both `vectorapi.env` and `runner.env`.
 - **cpp-httplib is pinned (`cmake/Dependencies.cmake`) and the pin carries its reasoning.** Currently v0.59.0. Check for an upgrade periodically: it serves the public HTTP surface AND every outbound call, upstream ships security fixes most releases, and we were 17 releases behind before anyone looked. When evaluating one, judge each fix against **what this service actually reaches** rather than the changelog's severity - `CPPHTTPLIB_REQUEST_URI_MAX_LENGTH` (8192, enforced before routing) means a long-path attack answers 414 before routing and never reaches the regex matcher, so the headline regex stack-overflow fix was never our exposure (verified against a running server, after first proving which process held the port - an earlier run of this test hit an unrelated service listening on the port I had picked), while the request-PARSING fixes (chunked transfer-coding matching, Content-Length truncation, chunk-size control characters) are. Deliberately NOT on the newest release when its fixes are for backends or features we do not use.

+ 1 - 1
VERSION

@@ -1 +1 @@
-0.9.2
+0.10.0

+ 2 - 2
runner/src/host_context.cpp

@@ -2593,7 +2593,7 @@ struct HostContext::Impl {
         int64_t keptBytes = 0;
         for (const uint64_t uid : uids) {
             const std::string headerBytes = mailCommand(
-                session, "fetch", net::imapUidFetch(tagger.next(), {uid}, "HEADER"));
+                session, "fetch", net::imapUidFetch(tagger.next(), std::vector<uint64_t>{uid}, "HEADER"));
             const net::ImapFetchResult headers = hostdetail::parseCurlFetch(headerBytes);
             // NOT just Malformed. NeedMore means the response is INCOMPLETE,
             // and by now the transport has finished the transfer - so it means
@@ -2604,7 +2604,7 @@ struct HostContext::Impl {
                 failMail("fetch", hostdetail::mailParseFailure(headers.status, "header fetch"));
 
             const std::string textBytes =
-                mailCommand(session, "fetch", net::imapUidFetch(tagger.next(), {uid}, "TEXT"));
+                mailCommand(session, "fetch", net::imapUidFetch(tagger.next(), std::vector<uint64_t>{uid}, "TEXT"));
             const net::ImapFetchResult bodies = hostdetail::parseCurlFetch(textBytes);
             if (bodies.status != net::ImapParse::Ok)
                 failMail("fetch", hostdetail::mailParseFailure(bodies.status, "body fetch"));

+ 7 - 0
runner/src/net/imap_commands.hpp

@@ -280,6 +280,13 @@ void imapValidateBodyPart(std::string_view spec);
 /// effect of reading, so a function that merely looked at a mailbox would mark
 /// mail read. The peek form is the only one a read surface may use, and the
 /// difference is invisible in a test that does not assert the exact bytes.
+///
+/// CALL THESE WITH AN EXPLICIT VECTOR TYPE. A braced list is viable for BOTH
+/// overloads - `{7, 9}` is either the SET `7,9` or the single RANGE `7:9`, and
+/// `{uid}` is either one uid or the range `uid:0` - so the two spellings mean
+/// different commands. GCC rejects the call as ambiguous where clang silently
+/// picks one, which is how this reached a release build having compiled
+/// cleanly on the dev host for days.
 ImapCommand imapUidFetch(std::string_view tag, const std::vector<uint64_t>& uids,
                          std::string_view bodyPart);
 ImapCommand imapUidFetch(std::string_view tag, const std::vector<ImapUidRange>& ranges,

+ 1 - 1
runner/tests/host_context_test.cpp

@@ -1276,7 +1276,7 @@ TEST(HostDetail, ACommandReachesTheTransportUntaggedAndWithoutItsTerminator) {
     // read. Asserted on the exact bytes, because the difference is invisible
     // otherwise.
     const std::string fetch = detail::customRequestFor(
-        svapi::runner::net::imapUidFetch(tagger.next(), {7, 9}, "HEADER"));
+        svapi::runner::net::imapUidFetch(tagger.next(), std::vector<uint64_t>{7, 9}, "HEADER"));
     EXPECT_EQ(fetch, "UID FETCH 7,9 (UID FLAGS INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER])");
 }