Repository navigation
Commit c05a8a0
fix(cloud-connection): a dry-run re-install answers a resolver refusal of either side with its 422, never a throw (#35347)
Fixes #34846
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:本地安装接口带 `dryRun: true` 预演重装时,如果「已装副本」或「新包」被今天的校验拒收,现在回 422
并点名是哪一份被拒,而不是直接抛错(传输层表现为 500)。
- 为什么改:真装一次早已回 422 并点名已装副本;同一个包预演却抛错,预演和真装的回答不一致。
- 风险与回滚:低。只在预演路径上、调用 `planUpgrade` 之前加一次与真装 2c″
完全相同的预解析;两份都合法时行为不变(CONTROL 用例钉住)。回滚即 revert 本 PR。
- 先看:`packages/cloud-connection/src/marketplace-install-local-plugin.ts`
的 `answerUpgradeDryRun` 新增的三行与抽出的 `upgradeSideRefusal`;其次新测试文件
`marketplace-install-local-dry-run-refusal-34846.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run
src/marketplace-install-local-dry-run-refusal-34846.test.ts`,预期 4 个用例全绿。
- 需要你做的:无,席位落地。
## What changes
- `answerUpgradeDryRun` (the `dryRun: true` branch of `POST
/api/v1/marketplace/install-local`) now pre-resolves both sides before
`planUpgrade` folds them, and answers a resolver refusal with
`declaredRefusalAnswer(manifestId, err, side)`: the refusal's own
declared status and code, with the sentence naming the stored copy (and
the remedy) or the incoming package. Before, the refusal left the door
as a throw.
- Step 2c″'s pre-resolve (incoming side first, then the installed side,
each in its own `try`) is extracted unchanged into one module-private
helper, `upgradeSideRefusal`, which both readers now call:
`evaluateDeclaredRenames` and `answerUpgradeDryRun`. An undeclared throw
is still rethrown, never relabelled.
- The 503 for a runtime with no `planUpgrade` is still answered first,
as before.
- Patch changeset for `@objectstack/cloud-connection`.
## Tests
New file
`packages/cloud-connection/src/marketplace-install-local-dry-run-refusal-34846.test.ts`,
driven through the real handler (harness as in the step 2c″ refusal
suite, with `planUpgrade` being the real fold plus
`comparePackageVersions`):
- installed copy refused, incoming well-formed: 422
`INVALID_ARTIFACT_PACKAGE_ENTRY`, message starts with the installed-copy
sentence, no plan read, nothing registered or synced, ledger
byte-identical;
- incoming refused, installed well-formed: 422 naming the incoming
package;
- both refused: the incoming refusal, asked first;
- CONTROL: both well-formed: 200 with the plan, `planUpgrade` called
once.
Red first, at `9e2b802c` (test only, code unchanged): 3 failed, 1 passed
(the CONTROL); each failure is the thrown `Release artifact packages[0]
is not a package entry (ADR-0130 D4): ... indexes[].unique: true was
retired ...`.
Ablation (committed fix at `d09cd19e`; the test imports the plugin from
`src`, so no rebuild is involved): `scripts/ablation-replace.mjs`
deleted the dry run's `if (refused) return c.json(refused.body,
refused.status);` (anchor 1 to 0, blob `ac4d332f` to `e09c14ed`), giving
3 failed and 1 passed. It then restored the file: blob `ac4d332f` equals
HEAD, and `git diff HEAD` is empty.
<details><summary>Package suite and typecheck at 986d579</summary>
`pnpm --filter @objectstack/cloud-connection exec vitest run
--maxWorkers=2 && pnpm --filter @objectstack/cloud-connection typecheck`
under the verify lock: `VERDICT command-exit 0`, Test Files 91 passed
(91), Tests 1330 passed (1330); typecheck ran `tsc --noEmit && tsc
--noEmit -p tsconfig.test.json` (the test config includes `src/**/*`, so
the new file is compiled).
</details>
## Acceptance notes
- The transport's 500 for the old throw was not re-measured. It is taken
from the real-runtime refusal suite's header, as the card says.
- The incoming-side refusal reaches the dry run only on a runtime that
predates the step-1c code judgements. A runtime that carries those
judgements answers the same refusal at step 1c first, as the real
install does. The installed side is read by no earlier step, so its
refusal reaches the dry run on every runtime. That case is the one this
fixes in practice.
- The dispatch named a new test file for this card. The step 2c″ refusal
suite would also have been a home, as a top-level `describe`. The
harness was copied from it rather than shared.
## Verification
<details><summary>Derived gate families (dispatch-gates --commands, 71)
at 986d579</summary>
69 exit 0. Two were NOT MEASURED, each exiting 3 on its own
prerequisite:
- `node scripts/check-plugin-teardown-shape.mjs --self-test` needs an
unshallow clone for its pinned positive control. It is a checker-health
check only.
- `pnpm check:dual-build-cjs-loads` reads every package's `dist`, and
this worktree built only the closure of cloud-connection.
Both are left to CI. `dispatch-gates --ran` reconciliation: 71 derived,
69 run, 2 NOT-MEASURED (derived from the recorded exit 3), 0 UNRUN.
`overlap-check --branch=HEAD`: `VERDICT clean exit 0`, merges cleanly
with origin/main.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CaysxGzF62ACvZ1x9x)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1aac465 commit c05a8a0
3 files changed
Lines changed: 317 additions & 22 deletions
File tree
- .changeset
- packages/cloud-connection/src
| 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 | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
532 | 574 | | |
533 | 575 | | |
534 | 576 | | |
| |||
4691 | 4733 | | |
4692 | 4734 | | |
4693 | 4735 | | |
4694 | | - | |
4695 | | - | |
4696 | | - | |
4697 | | - | |
4698 | | - | |
4699 | | - | |
4700 | | - | |
4701 | | - | |
4702 | | - | |
4703 | | - | |
4704 | | - | |
4705 | | - | |
4706 | | - | |
4707 | | - | |
4708 | | - | |
4709 | | - | |
4710 | | - | |
4711 | | - | |
4712 | | - | |
4713 | | - | |
| 4736 | + | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
4714 | 4740 | | |
4715 | 4741 | | |
4716 | 4742 | | |
| |||
6899 | 6925 | | |
6900 | 6926 | | |
6901 | 6927 | | |
6902 | | - | |
| 6928 | + | |
| 6929 | + | |
| 6930 | + | |
| 6931 | + | |
6903 | 6932 | | |
6904 | 6933 | | |
6905 | 6934 | | |
| |||
6922 | 6951 | | |
6923 | 6952 | | |
6924 | 6953 | | |
6925 | | - | |
| 6954 | + | |
| 6955 | + | |
| 6956 | + | |
| 6957 | + | |
| 6958 | + | |
| 6959 | + | |
| 6960 | + | |
| 6961 | + | |
| 6962 | + | |
6926 | 6963 | | |
6927 | 6964 | | |
6928 | 6965 | | |
| |||
0 commit comments