Skip to content

feat(connector-openapi): degrade + retry on an unreachable remote spec URL (#3049 follow-up)#3179

Merged
os-zhuang merged 1 commit into
mainfrom
claude/adr-0097-openapi-upstream-classify
Jul 18, 2026
Merged

feat(connector-openapi): degrade + retry on an unreachable remote spec URL (#3049 follow-up)#3179
os-zhuang merged 1 commit into
mainfrom
claude/adr-0097-openapi-upstream-classify

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

#3049connector-mcp 建立的「操作性故障 → 降级+重试」机制,对称地应用到 openapi provider 的远程 URL spec 拉取,补齐 ADR-0097 里记为延后的一条(现已删掉那句 caveat)。

问题

openapi provider 在 providerConfig.spec 为 http(s) URL 时于启动拉取文档。此前任何失败都普通抛出,于是 spec 端点一次瞬时不可达就拖垮整个应用启动——正是 #3049 为 mcp 修掉的「把操作性故障当致命」的形态,只是换了个 provider。

方案:同一套分类,provider 无关

loadOpenApiDocument 的远程分支现在区分:

情形 分类 行为
fetch 拒绝(DNS/连接拒绝/超时/网络错误) 操作性 ConnectorUpstreamUnavailableError降级+退避重试
瞬时 HTTP 状态 408/429/5xx(对齐 retryableStatusCodes 约定) 操作性 同上
错误 URL(非重试类 4xx:400/401/403/404/410…) 配置错误 普通抛出,boot 致命
2xx 但文档不可解析 / 非对象(数组) 内容错误 普通抛出,boot 致命(与 file-path 解析行为对称)

内联文档与 file-path spec(#3016)启动时无 I/O,不受影响

无需改 service-automation:#3049 的 reconcile 已经对任何带 CONNECTOR_UPSTREAM_UNAVAILABLE 标记的抛出走降级路径(provider 无关,已用 fake provider 通用证明)。因此降级态、GET /connectorsstate: 'degraded'、退避重试、metadata:reloaded 立即重试、恢复时原子替换——全部自动适用,与 mcp 同一条路径。

测试(provider 层,与 mcp 分类测试同一层次;+14 例,套件 32/32 绿)

  • 网络拒绝 → unavailable 且保留 cause;
  • 408/429/500/502/503/504 各自 → 降级(参数化);
  • 400/401/403/404/410 各自 → 保持致命(参数化);
  • 2xx 但 res.json() 抛错 / 返回数组 → 保持致命(内容错误)。

文档

本地:connector-openapi 构建绿、vitest 32/32、eslint 干净。

Refs #3049(降级+重试机制)、#3017、ADR-0097 §Upstream availability、ADR-0023。

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pbmw3pMqNJfPbkvwh9Fkjs


Generated by Claude Code

…c URL (#3049 follow-up)

The openapi provider fetches providerConfig.spec when it is an http(s) URL.
That fetch threw plain on any failure, so a momentarily-unreachable spec
endpoint aborted the whole app boot — the exact fail-loud-on-operational-fault
problem #3049 fixed for connector-mcp. Apply the same classification here:

- fetch rejection (DNS / connection refused / timeout / network error) or a
  transient HTTP status (408/429/5xx, mirroring the retryableStatusCodes
  convention) throws ConnectorUpstreamUnavailableError, so the materializer
  degrades the instance (state:'degraded' on GET /connectors) and retries with
  backoff plus on every metadata:reloaded — symmetric with mcp's connect path;
- a wrong URL (non-retryable 4xx) or an unparseable/non-object body stays a
  plain, fatal configuration fault;
- inline and file-path (#3016) specs do no boot I/O and are unaffected.

No service-automation change: the reconcile already routes any
CONNECTOR_UPSTREAM_UNAVAILABLE throw to the degrade path (provider-agnostic,
proven generically in #3049). Classification is tested at the provider layer
(matching mcp): +14 cases — network reject keeps cause, each of 408/429/5xx
degrades, each of 400/401/403/404/410 stays fatal, unparseable + array bodies
stay fatal.

ADR-0097 scope-boundary list updated: the openapi-fetch caveat is resolved,
and the stale 'live mcp demo deferred' bullet is trued up to as-built (#3062).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pbmw3pMqNJfPbkvwh9Fkjs
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Building Building Preview, Comment Jul 18, 2026 6:33am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling labels Jul 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

No hand-written docs reference the 1 changed package(s). ✅

@os-zhuang
os-zhuang marked this pull request as ready for review July 18, 2026 06:42
@os-zhuang
os-zhuang merged commit 41e703b into main Jul 18, 2026
15 of 16 checks passed
@os-zhuang
os-zhuang deleted the claude/adr-0097-openapi-upstream-classify branch July 18, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants