Repository navigation
fix(connectors)!: refuse a non-3.x OpenAPI document at load; mcp tools/list follows nextCursor and a 401/403 is a fatal configuration fault - #26798
Conversation
…load A Swagger 2.0 document loaded without any version check: host/basePath were ignored and body/formData parameters dropped, so the instance came up with wrong actions and no error. loadOpenApiDocument now checks the openapi field on every spec form (inline, URL, file) and throws a plain configuration fault naming the source and the offline conversion. Claude-Session: https://claude.ai/code/session_01QSeKYmG4MEJUzuz837U8Uq Co-authored-by: Claude <noreply@anthropic.com>
…al is a fatal configuration fault tools/list was called once with no cursor, so a paginating server lost every tool past its first page. The SDK-backed client now follows nextCursor until exhausted, bounded at 100 pages; a server still paging past the bound fails discovery loudly instead of yielding a truncated tool list. An HTTP 401/403 during connect, handshake or tools/list was wrapped as ConnectorUpstreamUnavailableError and retried as "server down". The provider now tells it apart by the SDK's own HTTP-transport error and throws it plain: a configuration fault, fatal at boot, never retried. Claude-Session: https://claude.ai/code/session_01QSeKYmG4MEJUzuz837U8Uq Co-authored-by: Claude <noreply@anthropic.com>
…tools/list paging and fatal 401 Claude-Session: https://claude.ai/code/session_01QSeKYmG4MEJUzuz837U8Uq Co-authored-by: Claude <noreply@anthropic.com>
…angesets Claude-Session: https://claude.ai/code/session_01QSeKYmG4MEJUzuz837U8Uq Co-authored-by: Claude <noreply@anthropic.com>
…'s configuration/operational split Claude-Session: https://claude.ai/code/session_01QSeKYmG4MEJUzuz837U8Uq Co-authored-by: Claude <noreply@anthropic.com>
… ratchet Claude-Session: https://claude.ai/code/session_01QSeKYmG4MEJUzuz837U8Uq Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check8 anchor(s) derived from 2 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 2 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 2047e2e3d102dc9b15490dd0b7299e05c16d4920 && git checkout 2047e2e3d102dc9b15490dd0b7299e05c16d4920
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 665059b6056c4caf54e631d678203d8c9dc4aba3 2177e83aa4d555a287a78a78696c8b9717198e8c && git checkout -B drift-repro 665059b6056c4caf54e631d678203d8c9dc4aba3 && git merge --no-ff 2177e83aa4d555a287a78a78696c8b9717198e8c
node scripts/docs-audit/affected-docs.mjs --json 665059b6056c4caf54e631d678203d8c9dc4aba3 |
Contract reviewServed-tier: Inputs: card #26709 (body and all four comments, the os-dev-report included); PR #26798 (body, nine-file list, the net diff against main from the merge base a485b5a); the check-runs on this head. Every required context is ① Derived judgments
② Semver levelTwo changesets — ③ Boundary flagsDev-report deviations: (1) the shared checkout was moved to a detached HEAD inside the dev's own cloud container so the platform branch could be checked out in a worktree — no other seat shares that container, and all six commits on the branch are that session's; no effect on the reviewed tree. (2) The commits carry the model-free session and co-author trailer pair and no model identifier — verified on all six. (3) Ablations ran against open_questions[0] — a server still paging past the 100-page bound on a declarative instance; shipped A (degraded and retried): ANSWERED, A holds. The mcp provider already classifies every post-connect content fault as operational (a malformed open_questions[1] — ADR-0097's sentence "The out_of_scope_findings: the programmatic Noted for the seat, not a finding on this PR: a non-retryable 400/404/410 on the MCP endpoint still degrades and retries, asymmetric with the openapi spec fetch's treatment of the same statuses; the card asks for 401/403 only. ④ Design judgmentpackages/connectors/connector-openapi/src/openapi-provider.ts — HOLDS. Tried to break it with: a numeric packages/connectors/connector-openapi/src/openapi-provider.test.ts — HOLDS. Each form (file, URL, inline) is pinned as a plain Error with packages/connectors/connector-mcp/src/mcp-connector.ts — HOLDS. Tried: a server repeating the same cursor (bounded, throws, the client is closed); an empty-string packages/connectors/connector-mcp/src/mcp-provider.ts — HOLDS, one should-fix. The classification keys on the SDK's class and status, never on a numeric code of a JSON-RPC error, and the lazy import is of a hard dependency, so this failure path cannot be replaced by an import failure. Boot: plain throw, then packages/connectors/connector-mcp/src/mcp-provider.test.ts — HOLDS. Injected clients throw the SDK's real classes; 401 on packages/connectors/connector-mcp/src/mcp-http-discovery-faults.test.ts — HOLDS. A real localhost Streamable-HTTP fixture reached through the real SDK client: two pages pinned with the cursors the server actually received; the endless pager pinned at exactly 100 Implemented-by: VERDICT: PASS Generated by Claude Code |
席位核对 · ACCEPT ·
|
Refs #26709 (items 2, 3a, 3b)
This PR carries items 2, 3(a) and 3(b) of the card's Work section. Items 1 (declarative
include), 3(c) (toolsSnapshotSha256) and 4 (the offline normalization tool) stay on the card: items 1 and 3(c) each add aproviderConfigkey, which triage's grade sends back to triage before it is built, and item 4 has no home yet.Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: updated here — content/docs/automation/connectors.mdx (no page under skills/ teaches the openapi or mcp provider:
git grep -i "swagger|tools/list|provider: 'openapi'|provider: 'mcp'" -- skillsreturns 0 hits)维护者速读
openapi连接器加载时拒收非 OpenAPI 3.x 文档(含 Swagger 2.0);mcp连接器的tools/list现在跟着nextCursor翻完所有页(上限 100 页);MCP 服务器对凭据回 401/403 时,实例直接判为配置错误,启动失败、不再重试。packages/connectors/connector-mcp/src/mcp-provider.ts(401/403 判定与 catch 分支,风险最高)、packages/connectors/connector-mcp/src/mcp-connector.ts(翻页循环与上限)、packages/connectors/connector-openapi/src/openapi-provider.ts(assertOpenApi3Document)。pnpm --filter @objectstack/connector-mcp exec vitest run src/mcp-http-discovery-faults.test.ts,预期 5 个用例全绿(真 HTTP MCP 服务器:两页工具全部发现;401 一次请求即失败、启动报错、不重试)。What changes
connector-openapi— only OpenAPI 3.x loads (item 2).loadOpenApiDocumentnow passes everyproviderConfig.specform (inline object, http(s) URL, package-relative file) throughassertOpenApi3Document: anopenapifield that is absent or not3.x(aswagger: "2.0"document included) throws a plain error, the provider's existing fatal path (fatal at boot, a skipped entry on reload; never the upstream-unavailable marker). The message names the source (file './x.json',URL '…'or(the inline document)), what was found (a Swagger "2.0" document,a document with no 'openapi' version field,a document declaring openapi: "4.0.0") and the remedy: convert to OpenAPI 3.x offline. Nothing is converted at runtime, and the instance never comes up half-mapped. 3.0 and 3.1 load as before.connector-mcp—tools/listpagination (item 3a). The SDK-backed client'slistTools()followsnextCursoruntil the server stops sending one, so every tool on every page becomes an action and is offered toproviderConfig.include. Bound:MCP_TOOLS_LIST_MAX_PAGES = 100. If the server is still answering anextCursorafter 100 pages, discovery throwsMCP server still returned a tools/list nextCursor after 100 pages (N tools so far); refusing to build the connector from a truncated tool list.A truncated list is never used. On a declarative instance, that failure is classified like any other failed discovery: the instance degrades with that reason and is retried (see open question 1).McpClientLike.listTools()is now documented as returning every page.connector-mcp— a rejected credential is a configuration fault (item 3b). In the provider's catch,credentialRejectionStatuslooks for an HTTP 401/403 on connect, handshake ortools/list. It recognises the MCP SDK's own transport errors (StreamableHTTPErrorwith code 401/403, orUnauthorizedError) anywhere in thecausechain; the SDK is imported lazily, only on this failure path. A match throws plain:connector-mcp provider: connector 'NAME' was refused by its MCP server (HTTP 401): … This is a configuration fault and is not retried — fix the credential and reload.A JSON-RPCMcpErrorthat merely carries code 401 is not a match, and every other connect or discovery failure keepsConnectorUpstreamUnavailableError. The comment that recorded today's opposite choice ("A credential the server rejects also lands here …") now states the new rule and its reason: retrying cannot make a credential valid, a degraded instance retried with backoff reads as "server down", and credential-protected remote servers are the common case. The comment cites ADR-0097's configuration/operational split and the openapi provider's matching treatment of a 401 on its spec fetch.content/docs/automation/connectors.mdxstates the 3.x-only rule, the pagination bound and the 401/403 classification.26709-openapi-refuse-swagger2.md,26709-mcp-tools-list-pages-fatal-401.md),minor(kindnarrowed), each with both declaration lines and an ADR-0087not-required (no-migration-prescription)disposition.Landing:
packages/connectors/connector-openapi/src/**andpackages/connectors/connector-mcp/src/**(the claimed file surface), plus the two changesets and the connectors docs page. Nothing underpackages/spec/**.Tests
connector-openapi/src/openapi-provider.test.ts, new block "refuses a document that is not OpenAPI 3.x": a Swagger 2.0 file-path spec, a Swagger 2.0 URL spec and an inline Swagger 2.0 document are each refused. Each refusal is asserted to be anErrorthat is NOT upstream-unavailable, and its message is asserted to name the file or URL andConvert the document to OpenAPI 3.x offline. A document with noopenapifield and one declaring4.0.0are refused the same way. Control: 3.0.3, 3.1.0 and 3.1 load.connector-mcp/src/mcp-http-discovery-faults.test.ts(new): a dependency-free Streamable-HTTP MCP server on an ephemeral localhost port, reached through the real SDK client (no injected client):tools/list: actions arealpha, beta, gamma, and the server saw the cursors[undefined, 'page-2'];tools/listcalls;is not retried, and the server received exactly one request;AutomationServicePlugin+ConnectorMcpPluginagainst a 401 server:kernel.bootstrap()rejects with the refusal, no degraded reason is recorded, and after 300 ms the server has still seen one request (no retry loop).connector-mcp/src/mcp-provider.test.ts, new block "a rejected credential is a configuration fault" (injected clients throwing the SDK's real error classes): 401/403 on connect, 401 ontools/list(client closed),UnauthorizedError, a 403 nested incause. Controls:StreamableHTTPError(503)andMcpError(401)stay upstream-unavailable.Acceptance notes
mcpprovider classifies connect /tools/listfailures as unavailable". This PR narrows that sentence to "except a rejected credential (401/403), which is a configuration fault", which is consistent with the ADR's own split: an unresolvablecredentialRefis already fatal there, and so is the openapi provider's 401 on its spec fetch.docs/adr/**is outside this card's file surface and is a governed surface, so the ADR is not edited here. A one-line amendment is owed; this is recorded in the dev report for the seat.loadOpenApiDocument, as the card names. The programmaticcreateOpenApiConnectorstill trusts its caller's document, as ADR-0023 states ("The caller is responsible for loading and de-referencing ($ref) the doc").MCP_TOOLS_LIST_MAX_PAGESis a module export ofmcp-connector.tsonly (the tests read it). It is not re-exported from the package entry, so the package's public surface is unchanged.Verification
All runs are on head
2177e83a(worktreeobjectstack-issue-26709, basea485b5a3).origin/mainhas since moved to4f05de4bwith 4 commits, none touchingpackages/connectors,packages/services/service-automationorpackages/spec/src/integration.Package tests and typecheck
Ablations (each put the forbidden behaviour back, saw red, restored; node scripts/ablation-replace.mjs, restore proven by blob == HEAD and empty git diff HEAD)
The tests import
src/directly (relative imports, no packageexportshop), so no rebuild was needed for an ablation to reach the code under test.Derived gates (node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack)
All other families (artifact rosters, wide-population, CI-only jobs, type-check lanes) are CI's: see this PR's check-runs.
Dogfood battery (Clause-② carries the (narrowing) arm)
Human Minimum
packages/specholds no runtime logic. (nopackages/specchange)pnpm lintis CI's).main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Dev seat: os-dev cloud session
session_01QSeKYmG4MEJUzuz837U8Uq, dispatched bydomain:server#3(session_01QSeKYmQXM3rHJcPnrEPk4B).🤖 Generated with Claude Code
Generated by Claude Code