Repository navigation
Commit c5fd012
fix(cloud-connection): install-local answers an artifact the resolver refuses with its 422 at the declared-rename step, not a 503 (#34573)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi96QpUuH77yeiDEFd5Vi6Pg1)_
Fixes #34432
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:install-local 的「声明式重命名」步骤(2c″)遇到解析器拒收的组合包(`packages`
不是数组、或某个包条目带已退役的 `indexes[].unique: true`)时,改为回答解析器自己的 422 与错误码,不再回答
503「数据库不可用、请重试」。
- 为什么改:包作者拿到的是错误归因,重试永远不会成功;同一份字节在 isolated 姿态的 2b 步骤已经回答 422,两个步骤口径不一致。
- 风险与回滚:只改 `@objectstack/cloud-connection` 一个文件的拒收答复,不写入任何数据;真正读不到表时仍回
503;未声明状态的异常(如包之间的依赖环)原样抛出。回滚即还原本 PR。
- 先看:`packages/cloud-connection/src/marketplace-install-local-plugin.ts`
的 `evaluateDeclaredRenames` 开头新增的预解析块,以及抽出的 `declaredRefusalAnswer`(2b 与
2c″ 共用);再看新测试
`marketplace-install-local-resolver-refusal-34432.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run
src/marketplace-install-local-resolver-refusal-34432.test.ts`,预期 5
个用例全绿(两条 422、一条 503 对照、一条 200 对照、一条依赖环原样抛出)。
- 需要你做的:无,席位落地。
## What changes
Step 2c″ of `POST /api/v1/marketplace/install-local`
(`evaluateDeclaredRenames`) caught every throw out of
`planDeclaredRenames` and answered it `503 SERVICE_UNAVAILABLE` "… could
not be read … Retry once the database answers". That included the
artifact resolver's declared `422` refusal of a composed body. The step
now:
- resolves the bodies the plan reads before any table is read, through
the plan's own fold (`packageUpgradeSideOf`: the
`resolveStackCollection` reads of `objects`, `objectExtensions` and
`data`; the installed body too on a re-install);
- answers a refusal there with that refusal's own declared status and
code (`422 INVALID_ARTIFACT_PACKAGES` /
`INVALID_ARTIFACT_PACKAGE_ENTRY`) and writes nothing;
- rethrows an undeclared throw out of the resolver (its dependency-cycle
error, a bare `Error`), and does not relabel it;
- keeps the `503` for a throw out of the plan itself, which is now only
the table read.
The reader is the one step 2b (#34428) answers the same refusal with. It
is extracted within the file as `declaredRefusalAnswer(manifestId,
err)`, so the two steps share one implementation and answer the same
bytes with the same status, code and sentence. Step 2b's behaviour is
byte-identical: same predicate (`declaredStatus === undefined || status
>= 500` ⇒ rethrow), same body, same status.
Changeset: `@objectstack/cloud-connection` patch.
## Tests
New file
`packages/cloud-connection/src/marketplace-install-local-resolver-refusal-34432.test.ts`.
It drives the real install route handler, under the `single` posture,
with the route-handler harness that #34428 used (runtime mocked without
the step-1c collectors):
- `packages: 'not-a-list'` ⇒ `422`, `error.code`
`INVALID_ARTIFACT_PACKAGES`. Nothing is registered, there is no ledger
entry, and the driver is never asked to read a table.
- A package entry with a retired bare `indexes[].unique: true` ⇒ `422`,
`INVALID_ARTIFACT_PACKAGE_ENTRY`. Nothing is written.
- CONTROL: a well-formed composed artifact whose renamed field's table
read throws ⇒ `503 SERVICE_UNAVAILABLE`, and nothing is written.
- CONTROL: the same artifact over a readable table ⇒ `200`.
- A dependency cycle between two packages (an undeclared resolver throw)
⇒ rethrown out of the handler, not answered `503`.
No existing test was changed.
<details><summary>Ablation (fix removed ⇒ red), via
scripts/ablation-replace.mjs</summary>
Mutation: ` packageUpgradeSideOf(converted);` ⇒ ` /* ABLATION-34432 */`
in `marketplace-install-local-plugin.ts`, at commit e6e6b07. The
anchor count went 1 ⇒ 0 and the blob went 8302cb3 ⇒ 07061200e185.
The test imports the plugin by relative path (source, not `dist/`), so
no rebuild sits in the loop.
- `Tests 3 failed | 2 passed (5)`: both 422 pins received `503
SERVICE_UNAVAILABLE` with the card's exact sentence ("the tables its
declared rename(s) carry could not be read (A release artifact's
`packages` must be an array …) … Retry once the database answers."). The
cycle pin received the `503` answer ("… could not be read ([Kernel]
Circular dependency detected: com.example.suite.core) …") and no throw.
- Both controls stayed green.
- Restore: `blob after restore 8302cb3 == blob at HEAD`, and `git
diff HEAD` is empty.
</details>
<details><summary>Package suite and typecheck at the final
head</summary>
After the closure rebuild (`pnpm --filter
'@objectstack/cloud-connection...' build`) at 18b6049:
- `pnpm --filter @objectstack/cloud-connection typecheck`: exit 0.
`tsconfig.test.json --listFiles` includes the new test file.
- `pnpm --filter @objectstack/cloud-connection exec vitest run
--maxWorkers=2`: `Test Files 89 passed (89)`, `Tests 1295 passed
(1295)`.
- Lock: `VERDICT command-exit 0`.
</details>
## Acceptance notes
- **Where this step is reached first.** The harness mocks
`@objectstack/runtime` without `collectJobsWithoutBody` /
`collectHooksWithoutBody`. That stands for a runtime that predates the
step-1c code judgements, and on such a runtime 2c″ is the first step to
resolve the packages. With the real runtime the same two bodies are
resolved first at step 1c (`unrunnableCode` ⇒ `collectBundleJobs` ⇒
`resolveArtifactCollections`), and the resolver's refusal leaves the
handler as a throw. I measured this by running the same pins once over
the real runtime: the throw comes out of `handleInstall` at the
`collectJobs(manifest)` call. The Hono transport's error seam
(`declaredEnvelopeForThrow`) then answers it `422` with the resolver's
code and reports a transport escape. That last part is read from
`plugin-hono-server/src/adapter.ts`, not measured. So on a current
runtime the client already saw the `422`, and this PR changes the 2c″
answer for the older-runtime composition. Step 1c answering the refusal
itself, as 2b and now 2c″ do, is outside this card.
- **What the 503 still covers.** A throw out of `planDeclaredRenames`
after the bodies resolved is answered as the table read. That is the
driver's introspection, plus any fault of the plan's own code, which
this step has always answered `503`. Telling those two apart needs a
marker at the driver call inside
`marketplace-install-declared-renames.ts`, which is outside this card's
file surface.
- **Read superset.** On a fresh install the pre-resolution also reads
`data`, which the plan alone does not read. A composed body the resolver
refuses only through `data` is now refused here, before any write.
Before, the `manifest` service refused it at register, on the same
bytes.
- A dependency cycle between packages of one artifact is a bare `Error`
by `resolveArtifactPackageOrder`'s documented contract
(`artifact-collections.ts` header). It is rethrown here and, by the
transport seam, answered `500 INTERNAL_ERROR` with no cause. Filed:
#34574.
- On a re-install the pre-resolution also folds the installed copy
(`packageUpgradeSideOf(installed)`). When today's resolver refuses that
stored copy, the answer is a 422 that names the incoming package
("Package 'X' cannot be installed"), and that side has no pin of its
own. Before this PR the same case answered 503, and step 2c′ folds the
installed copy again unguarded, so this is no new dead end, only a
misattributed message. Filed: #34583.
## Verification
Gates were run after the last commit, one at a time, each with stdin
closed. The derived list is `node scripts/pm/dispatch-gates.mjs
--commands --repo objectstack-ai/objectstack` at 18b6049 (3 paths, 71
commands). Reconciliation is `--ran` with `Run reconciliation — 71
derived, 71 run, 0 NOT-MEASURED, 0 UNRUN.`.
<details><summary>Gate results</summary>
All 71 exit 0. `check:dual-build-cjs-loads` first answered exit 3
(PREREQUISITE NOT MET, no `dist/`) and was re-run green after a
whole-workspace build (`turbo run build --filter=!@objectstack/docs
--concurrency=2`, lock VERDICT command-exit 0): `124 published require
entry point(s) across 72 package(s) load`.
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-command-ids :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:durability-log-level :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:error-status-conformance :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:init-service-contract :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:object-def-param-keys :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:optional-error-sink :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:route-envelope :: exit 0
pnpm check:settings-bind-window :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:startup-registry-verdict :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
</details>
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmRXuRn93HphKp7kXEz -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d7980d1 commit c5fd012
3 files changed
Lines changed: 313 additions & 13 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 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
477 | 510 | | |
478 | 511 | | |
479 | 512 | | |
| |||
3123 | 3156 | | |
3124 | 3157 | | |
3125 | 3158 | | |
3126 | | - | |
| 3159 | + | |
| 3160 | + | |
3127 | 3161 | | |
3128 | 3162 | | |
3129 | 3163 | | |
3130 | | - | |
3131 | | - | |
3132 | | - | |
3133 | | - | |
3134 | | - | |
3135 | | - | |
3136 | | - | |
3137 | | - | |
3138 | | - | |
3139 | | - | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
3140 | 3168 | | |
3141 | 3169 | | |
3142 | 3170 | | |
| |||
3204 | 3232 | | |
3205 | 3233 | | |
3206 | 3234 | | |
3207 | | - | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
3208 | 3239 | | |
3209 | 3240 | | |
3210 | 3241 | | |
| |||
4566 | 4597 | | |
4567 | 4598 | | |
4568 | 4599 | | |
| 4600 | + | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
4569 | 4606 | | |
4570 | 4607 | | |
4571 | 4608 | | |
| |||
4575 | 4612 | | |
4576 | 4613 | | |
4577 | 4614 | | |
4578 | | - | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
| 4624 | + | |
| 4625 | + | |
| 4626 | + | |
| 4627 | + | |
| 4628 | + | |
| 4629 | + | |
| 4630 | + | |
| 4631 | + | |
| 4632 | + | |
4579 | 4633 | | |
4580 | 4634 | | |
4581 | 4635 | | |
| |||
| 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 | + | |
0 commit comments