Skip to content

REST 若干 501 出口返回裸 { error: string },缺 machine code —— 跨对象批量路由等 #4067

Description

@os-zhuang

问题

REST 层大多数错误出口已带类型化 code(VALIDATION_FAILED / BATCH_NOT_ATOMIC / BATCH_TOO_LARGE / PERMISSION_DENIED …),clone 与 search 的 501 也已是 { error, code: 'NOT_IMPLEMENTED' }(rest-server.ts:4081,4959)。但有几处 501 出口仍返回裸 { error: '<string>' },缺 code,客户端无法按机器码区分:

位置 出口
rest-server.ts:6880 跨对象事务批量 POST {basePath}/batch —— 'Transactional batch not supported by this runtime'
rest-server.ts:3337 保存 meta item(路由 A)—— 'Save operation not supported by protocol implementation'
rest-server.ts:3720 保存 meta item(路由 B)—— 同上
rest-server.ts:3783 UI View 解析 —— 'UI View resolution not supported by protocol implementation'

其中 6880 是"批量 API 契约一致性"清扫线(承 #3897 / #3933 / #3939)的最后一处 —— 同路由的其余出口(BATCH_NOT_ATOMIC、VALIDATION_FAILED、enforceBatchSize 的 BATCH_TOO_LARGE)都已类型化,唯独运行时无事务支持这一 501 是裸串。另外三处是同形的 501 NOT_IMPLEMENTED 裸串,顺手一起收。

修法

按已有precedent(clone/search 501)给这四处补 code: 'NOT_IMPLEMENTED',保持 { error: '<message>', code } 扁平信封。纯新增字段、非破坏性:现有 501 测试只断言 status(501),error 文案不变。

补测试:把跨对象批量路由的 501 测试从只断言 status 扩展到断言 res.body.code === 'NOT_IMPLEMENTED'。

changeset:@objectstack/rest patch(additive)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions