|
117 | 117 | * the confirmation in the ledger entry. An orphaned install (the |
118 | 118 | * registry serves it, the ledger holds no record) is compared against |
119 | 119 | * the body the registry serves. A record of the installed version |
120 | | - * that will not parse, or an orphan whose registry row carries no |
121 | | - * body, answers the same 409 with one finding naming it |
122 | | - * (`installed_record_unreadable` / `installed_record_missing`): no |
123 | | - * comparison ran, and its token admits the re-install. Removed fields, |
124 | | - * `safe` type changes and seed changes are refused by nothing. |
| 120 | + * that will not parse, or no installed body anywhere (an entry or an |
| 121 | + * orphan's registry row carrying none), answers the same 409 with one |
| 122 | + * finding naming it (`installed_record_unreadable` / |
| 123 | + * `installed_record_missing`): no comparison ran, and its token admits |
| 124 | + * the re-install — unless the version declares a rename, still 501. |
| 125 | + * Removed fields, `safe` type changes and seed changes are refused by |
| 126 | + * nothing. |
125 | 127 | * |
126 | 128 | * [epic cloud#3652 Q3, #30884] `dryRun: true` answers `200` with the |
127 | 129 | * package upgrade plan — the installed version (its ledger entry) |
@@ -583,7 +585,11 @@ type SchemaUpgradeFinding = |
583 | 585 | describe: string; |
584 | 586 | } |
585 | 587 | | { |
586 | | - /** The registry serves the package but the ledger holds no record of it (an orphaned install). */ |
| 588 | + /** |
| 589 | + * No installed body to compare: the ledger entry parses but carries no |
| 590 | + * package body, or the registry serves the package while the ledger |
| 591 | + * holds no record of it (an orphaned install) and its row carries none. |
| 592 | + */ |
587 | 593 | kind: 'installed_record_missing'; |
588 | 594 | describe: string; |
589 | 595 | }; |
@@ -674,34 +680,74 @@ function schemaUpgradeFindingSet(manifestId: string, findings: readonly SchemaUp |
674 | 680 |
|
675 | 681 | /** |
676 | 682 | * [epic cloud#3652 Q3, #30884] The verdict when there is no installed side to |
677 | | - * compare: the ledger file would not parse, or neither the ledger nor the |
678 | | - * registry (an orphaned install's row) holds the installed body. The upgrade's |
679 | | - * renames and type changes cannot be known, and a comparison that did not |
680 | | - * run is never taken for "no finding" (2a, 2b and 2c answer the same way): the |
681 | | - * one finding names what is missing, and its token admits the re-install — |
682 | | - * the re-install that rewrites the record — confirmed and recorded, one round |
683 | | - * trip, never silently. |
| 683 | + * compare: the ledger file would not parse, its entry carries no package body, |
| 684 | + * or neither the ledger nor the registry (an orphaned install's row) holds |
| 685 | + * one. The upgrade's renames and type changes against the installed version |
| 686 | + * cannot be known, and a comparison that did not run is never taken for "no |
| 687 | + * finding" (2a, 2b and 2c answer the same way): the one finding names what is |
| 688 | + * missing, and its token admits the re-install — the re-install that rewrites |
| 689 | + * the record — confirmed and recorded, one round trip, never silently. |
| 690 | + * |
| 691 | + * A rename the incoming version declares is read from that version alone |
| 692 | + * ({@link declaredRenamesOfIncoming}) and still answers 501 (ruling record |
| 693 | + * 6709061297, C2): the token admits an unchecked re-install, never a rename |
| 694 | + * this runtime cannot carry. |
684 | 695 | */ |
685 | 696 | function installedRecordUnavailableVerdict( |
686 | 697 | manifestId: string, |
687 | 698 | failure: { file: string; cause: unknown } | undefined, |
| 699 | + incoming: PackageUpgradeSide, |
688 | 700 | ): { declaredRenames: UpgradePlanDeclaredRename[]; findings: SchemaUpgradeFinding[]; findingSet: string } { |
689 | 701 | const consequence = 'so this upgrade cannot be checked for fields it renames or retypes: confirming installs it ' |
690 | 702 | + 'unchecked, and the install rewrites the record.'; |
691 | 703 | const finding: SchemaUpgradeFinding = failure |
692 | 704 | ? { |
693 | 705 | kind: 'installed_record_unreadable', |
694 | 706 | file: failure.file, |
695 | | - cause: String((failure.cause as { message?: unknown } | null)?.message ?? failure.cause), |
| 707 | + cause: describeLedgerCause(failure.cause), |
696 | 708 | describe: `The record of the installed "${manifestId}" (${failure.file}) could not be read ` |
697 | | - + `(${String((failure.cause as { message?: unknown } | null)?.message ?? failure.cause)}), ${consequence}`, |
| 709 | + + `(${describeLedgerCause(failure.cause)}), ${consequence}`, |
698 | 710 | } |
699 | 711 | : { |
700 | 712 | kind: 'installed_record_missing', |
701 | | - describe: `This runtime serves "${manifestId}" but holds no record of the installed version's package body, ` |
702 | | - + consequence, |
| 713 | + describe: `This runtime holds no package body of the installed "${manifestId}" (neither its install record ` |
| 714 | + + `nor the registry carries one), ${consequence}`, |
703 | 715 | }; |
704 | | - return { declaredRenames: [], findings: [finding], findingSet: schemaUpgradeFindingSet(manifestId, [finding]) }; |
| 716 | + return { |
| 717 | + declaredRenames: declaredRenamesOfIncoming(incoming), |
| 718 | + findings: [finding], |
| 719 | + findingSet: schemaUpgradeFindingSet(manifestId, [finding]), |
| 720 | + }; |
| 721 | +} |
| 722 | + |
| 723 | +/** |
| 724 | + * [epic cloud#3652 Q3, #30884] The renames the incoming version declares, |
| 725 | + * read from it alone, for the verdict without an installed side: each field |
| 726 | + * whose `renamedFrom` names a key the same object no longer declares, as its |
| 727 | + * first such key ({@link comparePackageVersions} takes the first that the |
| 728 | + * installed version has; with no installed version, the first is the claim). |
| 729 | + * There is no `fromType`: the installed type is the unknown. |
| 730 | + */ |
| 731 | +function declaredRenamesOfIncoming(incoming: PackageUpgradeSide): UpgradePlanDeclaredRename[] { |
| 732 | + const renames: UpgradePlanDeclaredRename[] = []; |
| 733 | + for (const object of incoming.objects ?? []) { |
| 734 | + const o = object as { name?: unknown; fields?: unknown } | null; |
| 735 | + if (!o || typeof o.name !== 'string' || o.name === '' || !o.fields || typeof o.fields !== 'object') continue; |
| 736 | + const fields = o.fields as Record<string, unknown>; |
| 737 | + for (const [key, def] of Object.entries(fields)) { |
| 738 | + const d = def as { renamedFrom?: unknown; type?: unknown } | null; |
| 739 | + if (!d || !Array.isArray(d.renamedFrom)) continue; |
| 740 | + const from = d.renamedFrom.find((k): k is string => typeof k === 'string' && k !== '' && !(k in fields)); |
| 741 | + if (from === undefined) continue; |
| 742 | + renames.push({ |
| 743 | + object: o.name, |
| 744 | + from, |
| 745 | + to: key, |
| 746 | + ...(typeof d.type === 'string' && d.type !== '' ? { toType: d.type } : {}), |
| 747 | + }); |
| 748 | + } |
| 749 | + } |
| 750 | + return renames; |
705 | 751 | } |
706 | 752 |
|
707 | 753 | /** One side of the comparison, a multi-package artifact folded as `planUpgrade` folds it. */ |
@@ -3823,12 +3869,13 @@ export class MarketplaceInstallLocalPlugin implements Plugin { |
3823 | 3869 | * - **The installed side** is the ledger entry's body; for an orphaned |
3824 | 3870 | * install (no ledger file, the registry still serves the package) it is |
3825 | 3871 | * the body the registry serves ({@link registeredPackageBody}). |
3826 | | - * - **No installed body** (the ledger file would not parse, or neither the |
3827 | | - * ledger nor the registry holds one): no comparison can run, and one |
3828 | | - * that did not run is never taken for "no finding" — the 409 below with |
3829 | | - * one finding, `installed_record_unreadable` (its `file` and `cause`) or |
3830 | | - * `installed_record_missing`. Its token admits the re-install, which |
3831 | | - * rewrites the record, confirmed and recorded. |
| 3872 | + * - **No installed body** (the ledger file would not parse, its entry |
| 3873 | + * carries no body, or neither the ledger nor the registry holds one): no |
| 3874 | + * comparison can run, and one that did not run is never taken for "no |
| 3875 | + * finding" — the 409 below with one finding, `installed_record_unreadable` |
| 3876 | + * (its `file` and `cause`) or `installed_record_missing`. Its token admits |
| 3877 | + * the re-install, which rewrites the record, confirmed and recorded — but |
| 3878 | + * a rename the incoming version declares still answers the 501 below. |
3832 | 3879 | * - **A declared rename**: `501 NOT_IMPLEMENTED`, naming each — no token |
3833 | 3880 | * answers it while this runtime cannot carry a renamed field's column to |
3834 | 3881 | * its new key (ruling record 6709061297, C2). Card 01b (#30885), which |
@@ -3858,14 +3905,15 @@ export class MarketplaceInstallLocalPlugin implements Plugin { |
3858 | 3905 | // The installed side: the ledger entry's body; for an orphaned install |
3859 | 3906 | // (no ledger file, the registry still serves the package — findConflict |
3860 | 3907 | // step 3) the body the registry serves. With neither — a ledger file |
3861 | | - // that will not parse, or a registry row carrying no body — the verdict |
3862 | | - // is the one finding that says so, confirmable like any other, never |
3863 | | - // "no finding". |
| 3908 | + // that will not parse, an entry or a registry row carrying no body — |
| 3909 | + // the verdict is the one finding that says so, confirmable like any |
| 3910 | + // other, never "no finding"; a rename the incoming version declares |
| 3911 | + // still answers 501. |
3864 | 3912 | const installedBody = previous.entry?.manifest |
3865 | 3913 | ?? (previous.entry === null && previous.failure === undefined ? this.registeredPackageBody(ctx, manifestId) : undefined); |
3866 | 3914 | const installed = installedBody ? this.convertPackageBodyForward(ctx, installedBody) : undefined; |
3867 | 3915 | const verdict = installed === undefined |
3868 | | - ? installedRecordUnavailableVerdict(manifestId, previous.failure) |
| 3916 | + ? installedRecordUnavailableVerdict(manifestId, previous.failure, packageUpgradeSideOf(converted)) |
3869 | 3917 | : schemaUpgradeVerdict(manifestId, comparePackageVersions(packageUpgradeSideOf(installed), packageUpgradeSideOf(converted))); |
3870 | 3918 | const { declaredRenames, findingSet } = verdict; |
3871 | 3919 | if (declaredRenames.length === 0 && verdict.findings.length === 0) return {}; |
@@ -3920,7 +3968,8 @@ export class MarketplaceInstallLocalPlugin implements Plugin { |
3920 | 3968 | + 'the new field would start empty while the values stay in the old column. Nothing was ' |
3921 | 3969 | + 'installed or written. Install this version once the runtime carries declared renames; or, ' |
3922 | 3970 | + 'to install it now without moving the values, remove the `renamedFrom` declaration, ' |
3923 | | - + 'rebuild, and confirm the suspected rename the next refusal lists.' |
| 3971 | + + 'rebuild, and confirm what the next refusal lists (a suspected rename, or the ' |
| 3972 | + + 'installed record it could not read).' |
3924 | 3973 | + (findings.length > 0 |
3925 | 3974 | ? ` That refusal will also ask to confirm ${findings.length} other finding(s), listed here.` |
3926 | 3975 | : ''), |
@@ -4945,6 +4994,10 @@ export class MarketplaceInstallLocalPlugin implements Plugin { |
4945 | 4994 | * under `manifestId` — the row {@link findConflict} step 3 finds for an |
4946 | 4995 | * orphaned install — or `undefined` when there is none, or it carries no |
4947 | 4996 | * body. Step 2c′ compares against it when the ledger holds no record. |
| 4997 | + * |
| 4998 | + * One row, the one {@link findConflict} matches: for an artifact that |
| 4999 | + * bundles several packages, the other packages' rows are not folded in, |
| 5000 | + * so their objects read as added (never refused) rather than compared. |
4948 | 5001 | */ |
4949 | 5002 | private registeredPackageBody = (ctx: PluginContext, manifestId: string): unknown => { |
4950 | 5003 | try { |
|
0 commit comments