Repository navigation
Commit e66e309
fix(service-datasource): migrateCredential's drop-inline refusal names an empty stored credential as empty (#29192)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9VrDSYbFeBRpZi2Rbi1iw6B)_
Fixes #29069
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:数据源凭据迁移(drop-inline)遇到已绑定的 sys_secret
解密出来是空值时,拒绝理由现在说「凭据为空」,用的是 #29064 连接路径同一句话;真的找不到行或密钥变了时,原来那句不变。
- **为什么改**:以前两种情况共用一句「sys_secret 行丢失或加密密钥变了」,空凭据的管理员会去查错地方。
- **风险与回滚**:极低。只改拒绝文案;结果仍是 `refused`、什么都不写、内联凭据保留。回滚即 revert。
-
**先看**:`packages/services/service-datasource/src/datasource-admin-service.ts`
的 `migrateCredential` 里新拆出的 `resolved === ''` 分支。
- **两分钟验证**:`pnpm --filter @objectstack/service-datasource exec vitest
run src/__tests__/datasource-admin-service.test.ts`,预期 `Tests 39 passed
(39)`(main 上新用例红)。
- **需要你做的**:无,席位落地。
## What changes
- `migrateCredential`'s drop-inline step (`datasource-admin-service.ts`)
splits its refusal. A ref that resolves to `''` is refused with:
"Datasource 'NAME' already references a stored secret, but credential
'REF' is empty (its sys_secret row holds an empty value). Removing the
inline credential would leave this datasource with no working credential
at all." The middle clause is the connect path's sentence from PR #29064
(`DatasourceConnectionService.connect`, the `secret === ''` branch),
byte for byte. The remedy says to set the datasource's secret again.
- A ref that does not resolve (`undefined`: a missing row or a decrypt
failure) keeps its sentence and remedy unchanged.
- Same outcome on both branches: `status: 'refused'`, no write, the
inline copy kept. No new error code, status or member; the result shape
is unchanged.
- Changeset `.changeset/29069-migrate-credential-empty-refusal.md`:
`patch` on `@objectstack/service-datasource`.
## Tests
`src/__tests__/datasource-admin-service.test.ts`, `migrateCredential
(#8155)` block:
- **Forced test edit:** the existing "cannot be resolved" case moved
from `toContain('could not be resolved')` to an exact pin of the
missing-row sentence, plus its remedy, so the unchanged text is held
(the card asks a test to pin both texts).
- **New:** a ref whose read-back is `''` is refused with the
empty-credential sentence exactly, the reason names neither "could not
be resolved" nor "encryption key", the remedy says to set the secret
again, the inline password stays and the only store call is the read.
<details><summary>Red on base, green on head, ablation</summary>
- **Red** (tests at head, source at base `fea2dbb7`): `Tests 1 failed |
38 passed (39)`; the new case received the missing-row sentence. The
missing-row pin was green on base, as it should be.
- **Green** (head `b213c369`): `Tests 39 passed (39)`.
- **Ablation** (`scripts/ablation-replace.mjs`, the whole `resolved ===
''` branch replaced by the old conflated condition `if (resolved == null
|| resolved === '') {`, anchor 1 -> 0, blob `144b0a89` -> `bcdb23c3`):
`Tests 1 failed | 38 passed (39)`; Expected the empty sentence, Received
"…but it could not be resolved or decrypted (a missing `sys_secret` row,
or a changed encryption key)…". Restore: blob after restore `144b0a89`
equals HEAD's, `git diff HEAD` empty.
</details>
## Acceptance notes
- The empty-credential clause is spelled in two places now (the connect
path and this refusal). The claim's file surface is the admin service
only, so no shared helper was extracted into
`datasource-connection-service.ts`; each spelling is pinned by its own
test.
## Verification
All readings at head `b213c369`.
<details><summary>Package suite, typecheck, lint</summary>
- `pnpm --filter @objectstack/service-datasource test`: `Test Files 69
passed (69)`, `Tests 1153 passed (1153)`, exit 0.
- `pnpm --filter @objectstack/service-datasource typecheck`: exit 0.
- eslint `--no-inline-config` on the two changed source files: exit 0.
Repo-wide `pnpm lint` is CI's.
</details>
<details><summary>Derived gates (dispatch-gates.mjs --commands, 61
families)</summary>
- 60 of 61 run locally, all exit 0. `check-plugin-teardown-shape
--self-test` first exited 3 on a shallow clone; after `git fetch
--unshallow` it passed (48 cases).
- `pnpm check:dual-build-cjs-loads` needs every package built; the full
build runs and the reading goes in the os-dev-report, otherwise CI's
check-run is the reading.
</details>
Dogfood battery: not owed (no `!` in the title, no `(narrowing)` arm).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmP66rDL21VeBrVWovN)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent f6a04e3 commit e66e309
3 files changed
Lines changed: 57 additions & 2 deletions
File tree
- .changeset
- packages/services/service-datasource/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
635 | 640 | | |
636 | 641 | | |
637 | 642 | | |
638 | 643 | | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
639 | 669 | | |
640 | 670 | | |
641 | 671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1176 | 1176 | | |
1177 | 1177 | | |
1178 | 1178 | | |
1179 | | - | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
1180 | 1195 | | |
1181 | 1196 | | |
1182 | 1197 | | |
| |||
0 commit comments