fix(service-datasource,rest): the last three uncovered datasource routes answer their registered refusal code (#4264) - #4313
Merged
Conversation
…tes answer their registered refusal code (#4264) #4249 (#4263) gave the rest surface's two introspection routes a failure contract; three sibling routes still had no catch around their service call, so a throw was swallowed by the adapter and surfaced as the pre-#3675 non-envelope 500 { error: 'No response from handler' } — no success flag, no error.message, the real cause lost. Each now answers 400 in the declared envelope, under the code registered (ADR-0112) for the service the route dispatches to: - GET /api/v1/datasources → DATASOURCE_ADMIN_ERROR, matching its eight siblings in admin-routes.ts - POST /datasources/:name/external/refresh-catalog and POST /datasources/:name/external/validate → EXTERNAL_DATASOURCE_ERROR, the code #4249 gave the two introspection routes above them The issue left INTERNAL_ERROR open as an alternative; the per-service codes win on consistency — every other catch in both modules, including pure reads, already answers 400 with the service-attributed code, and refreshCatalog's dominant throw class is the one #4249 already adjudicated as a 400 refusal on listRemoteTables. A 500 would fork the failure contract within a module — the drift #4249 removed. No new codes (both registered by #4263). The envelope-conformance suites and the REFUSALS pin table gain one row per route. Closes #4264 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VDgGWS97x6vuikjmgMswtk
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4264(#4249 / #4263 的后续)。
问题
#4263 只覆盖了 issue 点名的两条 introspection 路由;还剩三条兄弟路由的服务调用完全没有
catch,服务一抛,rejection 被适配器吞掉(.catch(() => resolve(null))),客户端拿到的是 pre-#3675 形态的非信封500 { error: 'No response from handler' }—— 没有success标志、body.error.message === undefined、没有可切换的 code,真实原因彻底丢失。修复
形状与 #4249 完全相同:包住服务调用,回
400声明信封,error.code用该路由所派发服务在 ADR-0112 账本中注册的 refusal code,error.message携带服务自己的消息:GET /api/v1/datasourceslistDatasources400 DATASOURCE_ADMIN_ERRORPOST /api/v1/datasources/:name/external/refresh-catalogrefreshCatalog400 EXTERNAL_DATASOURCE_ERRORPOST /api/v1/datasources/:name/external/validatevalidateAll400 EXTERNAL_DATASOURCE_ERROR裁决:注册 refusal code,而非
INTERNAL_ERRORIssue 留了一个待裁决点(
listDatasources失败更像后端故障)。本 PR 选注册 code,理由:getDatasource、listRemoteTables)—— 都已经以 400 + 服务归属 code 应答。这三条改回 500 会在同一模块内分叉失败契约,正是 The same three datasource-admin routes answer 400 with the wrong service's error code (#4225 follow-up, one field over) #4249 消除的那类漂移("one operation, one failure contract")。refreshCatalog的主要抛出类别(未知 datasource、远端不可达、no such schema)与listRemoteTables完全同类,The same three datasource-admin routes answer 400 with the wrong service's error code (#4225 follow-up, one field over) #4249 已把后者裁为 400 refusal。INTERNAL_ERROR会抹掉这一机器可读归属。若维护者仍倾向
INTERNAL_ERROR,改动集中在两处 helper,易于翻转。变更明细
service-datasource/admin-routes.ts—GET /datasources包上 try/catch →badRequest(res, 'datasource-admin', err)。rest/external-datasource-routes.ts—refresh-catalog/validate包上 try/catch;introspectionRefused更名为refused(自 Three datasource routes still surface a service throw as the adapter's non-envelope 500 (#4249 follow-up) #4264 起除 import 外每条路由的 catch 都用它,名字随服务而非单一操作);模块头注释补记 Three datasource routes still surface a service throw as the adapter's non-envelope 500 (#4249 follow-up) #4264。admin-routes.test.ts的REFUSALSpin 表 +1 row(GET /datasources)。验证
service-datasource全套 10 files / 180 tests 通过;rest全套 35 files / 523 tests 通过。scripts/check-route-envelope.mjs通过(该门审计写点,本次只新增经sendError的写点)。Generated by Claude Code