boardx / boardx/workspacex

gates-runtime G3「不回显提交值」断言会被随机 traceId 撞红(含 "123" 的 UUID)

Open Beginner friendly
#2,545 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
1h 7m
Merged PRs (30d)
969

Description

## 现象

PR #2538 head `f6247e9` 的 backend-gates `gates-runtime` job(run [33669515420](https://github.com/boardx/workspacex/actions/runs/33669515420/job/100379357132))红:

```
✗ G3 the response does not echo the submitted values back -- {"error":"validation_failed","traceId":"e495a188-62d9-4495-8d15-1070f8b1231f","fields":[{"path":"orgId","code":"invalid_type"},{"path":"object.kind","code":"invalid_enum_value"},{"path":"action","code":"invalid_type"}]}
```

响应的业务字段(`error` / `fields[].path,code`)没有回显任何提交值。红的原因是随机 traceId `…-8d15-1070f8b1231f` 恰好含子串 `123`。

## 根因

`apps/api/scripts/runtime-gate-assert.ts` G3 断言:

```ts
!JSON.stringify(g3body).includes("123") && !JSON.stringify(g3body).includes("nope")
```

对**整个**响应体(含随机 UUID `traceId`)做子串匹配。UUID 32 个十六进制字符里出现 `123` 的概率约 3%,每次 push 都有机会随机红;同一 SHA 重跑即绿,与被测代码无关。

## 修法(一行)

判定改为对去掉 `traceId` 的响应体做:

```ts
const { traceId: _g3TraceId, ...g3bodyWithoutTraceId } = g3body as { traceId?: string } & typeof g3body;
check(
"G3 the response does not echo the submitted values back",
!JSON.stringify(g3bodyWithoutTraceId).includes("123") && !JSON.stringify(g3bodyWithoutTraceId).includes("nope"),
JSON.stringify(g3body),
);
```

该补丁曾作为 PR #2538 的 `8a146c7` 推上去过,reviewer 指出与 #2535 无关、需单独 issue/PR 追踪(一个 issue 一个 PR),已从该 PR revert。请在独立分支下走本 issue。

## 验证

- 本地:`apps/api/scripts/verify-runtime-gates.sh` 通过。
- 反证:把 `traceId` 固定为含 `123` 的值跑一次 G3,改动前红、改动后绿。

Contributor guide

No contributing guide indexed for this repository

Research direction

Open apps/api/scripts/runtime-gate-assert.ts and inspect the G3 assertion that checks the serialized response. Run apps/api/scripts/verify-runtime-gates.sh, then verify that a traceId containing "123" no longer causes G3 to fail while submitted values are still rejected. Keep the change limited to the independent fix described in this issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell, typescript
Domain
ci-cd, testing
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
92/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.