Repository navigation
fix(core): os test --url with a trailing slash addresses the served routes - #28999
Conversation
…os test --url addresses the served routes Strip trailing slashes from the base once, in the constructor, so the discovery probe, record collection URLs, api_call relative targets and the provenance clauses all read the same base. A failed api_call (404/405) now names the URL it addressed, as record actions already name their mount. Claude-Session: https://claude.ai/code/session_01FEkQ5nPQ5s2XpToMJtoBDm Co-Authored-By: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 39 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 72853c5fee8005b2597d8fd9edd5f7f85b4ff441 && git checkout 72853c5fee8005b2597d8fd9edd5f7f85b4ff441
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin cae71fedfc8f04d35694da55ab74f9d680da0c5f 4ff51b5563b95702dea9bbaaf848cf649d6ed916 && git checkout -B drift-repro cae71fedfc8f04d35694da55ab74f9d680da0c5f && git merge --no-ff 4ff51b5563b95702dea9bbaaf848cf649d6ed916
node scripts/docs-audit/affected-docs.mjs --json cae71fedfc8f04d35694da55ab74f9d680da0c5f
|
|
domain:server#3 · os-project-manager · session_01FEkQ5kE5BrPUPNMMyv6oCH 席位核对 · ACCEPT · PR #28999 · 2026-11-02T06:02ZHead-sha: 维护者速读(席位终稿)
核对六项
|
Requested by Leehom · project thread
Fixes #28946
Clause-②: no — no schema, type, export or route change; a
--urlthat answered every HTTP scenario 404 now reaches the served routes.Metadata-protocol: none — nothing a metadata author writes is read differently;
qa/*.test.jsonsuites are unchanged.维护者速读
HttpTestAdapter在构造函数里把 base URL 末尾的斜杠一次性去掉,于是发现探针、记录动作 URL、api_call相对路径和报错里的 URL 都读同一个规整后的 base。api_call遇到 404/405 时,报错句末尾追加它实际请求的方法 + URL,和记录动作已有的写法一致。os test --url http://localhost:PORT/(带末尾斜杠)会请求//api/v1/...,服务端回 404ENDPOINT_NOT_FOUND,每个 HTTP 场景都失败,而且api_call的报错不说它请求了哪个 URL,看起来像应用坏了。--url行为不变。回滚即 revert。packages/core/src/qa/http-adapter.ts的构造函数与rawApiCall末尾;packages/core/src/qa/http-adapter.test.ts末尾新增的 describe 与改过的[#7983] an api_call failure ...用例。pnpm --filter @objectstack/core exec vitest run src/qa/http-adapter.test.ts,预期Tests 52 passed (52)。What changes
packages/core/src/qa/http-adapter.ts: the constructor storesbaseUrlwith its trailing slashes stripped (private readonly baseUrl), once. Every URL the adapter builds reads that field: the discovery probe,collectionUrl/recordUrl,api_call's relative target, and the record-actions provenance clause.HttpTestAdapterhas one caller (packages/cli/src/commands/test.ts, which hands it--urlverbatim), so normalising in the adapter covers it and any future caller;Test.runis unchanged. No flag, no URL validation: a malformed--urlbehaves as it did.rawApiCallhandshandleResponsethe clauseapi_call addressed METHOD URL, so anapi_callthat fails 404 or 405 ends its existingHTTP Error STATUS: BODYsentence with one added clause naming the URL it addressed. The 404/405 gate is the one record actions already use: other statuses reached a route, so the server's own message stays undecorated.handleResponse's parameter is renamedmountNote→addressNote, since it now carries either..changeset/28946-qa-base-url-trailing-slash.md:@objectstack/corepatch with both declaration lines. The CLI is unchanged (its dist imports@objectstack/coreexternally), so it carries no changeset.Tests
http-adapter.test.ts, three rows (http://localhost:3000/,http://localhost:3000//,http://localhost:3000/prefix/) × four cases, against a capturedfetch: the probe plus the record collection URL carry one slash; anapi_callrelative target carries one slash; the record-actions clause names the normalised base and probe; anapi_call404 names the normalised URL.[#7983] an api_call failure is not decorated with a mount it never usedpinned the exact undecorated 404 message. Per the order's ruling it now asserts the added URL clause and still asserts no mount clause. A new case pins that anapi_call422 stays undecorated.scripts/ablation-replace.mjs, anchor hit once, blob3c016586→f4f31939): the constructor keptbaseUrlverbatim. 12 failed / 40 passed; for example, expectedhttp://localhost:3000/api/v1/objects/crm_account, receivedhttp://localhost:3000//api/v1/data/crm_account(the doubled-slash probe misses discovery, too). Restored: blob equals HEAD's,git diff HEADempty.3c016586→43092308):rawApiCallpassed no clause. 4 failed / 48 passed (the rewrittenHttpTestAdapter's record action types resolve the DEFAULT API mount only — a deployment that setsapi.apiPathorcrud.dataPrefixis unreachable #7983 case and the three per-rowapi_call404 cases). Restored the same way../http-adapter.jsfrom source, so no build sits on the ablation path.Acceptance notes
Measured on a stock showcase boot (
objectstack dev --seed-admin --fresh, admin token fromsign-in/email) before and after, with the showcase'sqa/platform-smoke.test.jsonand a two-scenario suite (onecreate_record, oneapi_call):--url135054eb4ff51b55http://localhost:PORThttp://localhost:PORT/http://localhost:PORT//http://localhost:PORT/prefix/.../prefix//api/v1/dataapi_call addressed GET http://localhost:PORT/prefix/api/v1/health;record actions addressed http://localhost:PORT/prefix/api/v1/dataBefore the fix, an
api_call404 printed onlyHTTP Error 404: {"success":false,"error":{"code":"ENDPOINT_NOT_FOUND","message":"Not found"}}, with no URL.Verification
All at head
4ff51b55(base135054eb,origin/mainwhen the branch was cut).Package suite, typecheck, lint (under the verify lock)
pnpm --filter @objectstack/core test: Test Files 129 passed (129), Tests 2905 passed (2905).pnpm --filter @objectstack/core typecheck(tsc --noEmitpluscheck:test-typecheckovertsconfig.test.json, which covers the test file): exit 0.pnpm exec eslint --no-inline-config packages/core: exit 0.test:repo(core'srepovitest project) was not run locally: the diff touches no census pin and the derivation does not name it. CI Test Core runs it.Derived gates (dispatch-gates --commands, 59 families)
dispatch-gates.mjs --ran: "59 derived famil(ies) accounted for — 58 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)".pnpm check:dual-build-cjs-loads, exit 3 (PREREQUISITE NOT MET: packages outside the showcase closure have nodist). CI runs it.check-plugin-teardown-shape.mjs --self-testran aftergit fetch --depth=1 origin 621a4876(the shallow-clone prerequisite).CI check-runs: read by the seat on this head.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5nPQ5s2XpToMJtoBDm
Generated by Claude Code