iloveeyjafjalla opened a new pull request, #6732:
URL: https://github.com/apache/rocketmq-dashboard/pull/6732
### Which Issue(s) This PR Fixes
- Fixes #6731
### Brief Description
`npm run build` is `tsc -b && vite build && npm run license:check`, and the
current `rocketmq-studio`
tip does not pass the first step:
```
src/pages/ops/__tests__/auditRiskInsights.test.ts(193,23): error TS2322:
Type 'null' is not assignable to type 'string | undefined'.
src/pages/ops/__tests__/auditRiskInsights.test.ts(195,23): error TS2322:
Type 'null' is not assignable to type 'string | undefined'.
```
The test merged in #6367 (`0e73d289`) documents that an audit row can carry
no operator (`operator:
null`) next to one literally named `system`, while `AuditRecord.operator` is
typed as a non-null
string. The column is nullable in the schema (`rmq_operation_audit.operator
varchar(128) NULL`) and
every renderer already falls back — `issue.operator ?? '-'` in
`AuditRiskInsights.tsx`,
`record.operator || '-'` in `ResourceOperationTimelineModal.tsx`,
`a.operator ?? ''` in the audit
table's sorter — so the type is the stale half of the pair, not the test.
- `web/src/api/ops.ts`: `operator: string | null`, with a one-line comment
saying why.
- No behaviour change and no other call site needed touching: `tsc -b` is
clean afterwards, which is
what proves the widening is sufficient.
### How Did You Test This Change?
Red first, on the current tip (`7d8f1936`), before the change:
```
$ cd web && npx tsc -b
src/pages/ops/__tests__/auditRiskInsights.test.ts(193,23): error TS2322:
Type 'null' is not assignable to type 'string | undefined'.
src/pages/ops/__tests__/auditRiskInsights.test.ts(195,23): error TS2322:
Type 'null' is not assignable to type 'string | undefined'.
(exit 1)
```
Green with the change:
```
$ cd web && npx tsc -b
(exit 0)
$ npx vitest run src/pages/ops/__tests__/auditRiskInsights.test.ts
src/pages/ops/__tests__/AuditPage.test.tsx
src/pages/ops/__tests__/AuditRiskInsights.test.tsx
src/pages/ops/__tests__/AuditSummaryCards.test.tsx --maxWorkers=1
Test Files 4 passed (4)
Tests 33 passed (33)
$ npx eslint src/api/ops.ts
(clean)
$ npx prettier --check src/api/ops.ts
All matched files use Prettier code style!
```
The regression guard is the test #6367 already merged: it is the assertion
that a null operator is a
real state, and it cannot even compile until the type admits it.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`fix(web): ...`)
- [x] Tests added or updated for non-trivial changes — the merged
`auditRiskInsights` case is the
guard: it fails to compile before and passes after, and the four audit
suites stay green
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
— no UI text changed
- [x] Architecture constraints stay green — no Java/backend change, so the
ArchUnit checks are untouched
- [x] New source files carry the ASF license header — no new files
- [x] Documentation touched where behaviour changed — the type carries a
one-line comment explaining
the null
Disclosed rather than left to be discovered on merge: the audit area is
being refactored in flight.
#6686 rewrites `AuditRiskInsights.tsx`, `audit.tsx`,
`auditRiskInsightModel.ts` and its tests, and
#6131 edits `AuditRiskInsights.tsx`; neither touches `web/src/api/ops.ts`,
so this change does not
overlap them, but a rebase of either onto each other stays straightforward.
AI assistance: the analysis, the change and the verification were produced
with AI assistance (an
agent working in this repository) and reviewed by me before submission; the
command output above is
from the actual runs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]