Skip to content

幂等键被同时发送到请求体 / Idempotency key is also sent in request bodies #147

@saxon134

Description

@saxon134

问题 / Problem

中文:VideosResource.createTasksResource.createparams.get("idempotency_key") 生成 Idempotency-Key header,但同一个 params 又传给 _payload 作为 JSON body,因此调用 create(..., idempotency_key="idem_1") 会同时发送 header 和 body 字段 idempotency_key。如果服务端 schema 不接受该字段,请求会被拒绝;即使接受,也会把只应属于传输层的控制参数混入业务 payload。修复应在构造 body 前移除 idempotency_key。价值:减少 4xx 请求失败和排障成本,让 SDK 参数语义更清晰可靠。English: VideosResource.create and TasksResource.create derive the Idempotency-Key header from params.get("idempotency_key"), but the same params is also passed to _payload as the JSON body, so create(..., idempotency_key="idem_1") sends both the header and a body field named idempotency_key. If the server schema rejects unknown fields, the request fails; even if accepted, a transport control parameter leaks into the business payload. Remove idempotency_key before building the body. Value: fewer 4xx failures and lower debugging cost, with clearer SDK parameter semantics.

价值 / Value

修复该问题可以提升正确性、可靠性和用户信任,降低 idempotency_key leaked into create request bodies 带来的排障与运维成本。

Fixing this issue improves correctness, reliability, and user trust while reducing debugging and operational cost caused by idempotency_key leaked into create request bodies.

证据 / Evidence

File: src/globalrouter/_resources.py

Line: 335

Severity / 严重级别: medium

Summary / 摘要: idempotency_key leaked into create request bodies

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions