Commit 7e77b42
fix(sdk): re-plan after commit for image puts to surface v1.49 variants
The gateway generates image variants AT COMMIT TIME (parent gateway
change Section 5 — prepareStagedAssetVariants runs before the
activation txn opens). The plan response that funds DeployResult.assets
is built BEFORE commit, so its asset_entries[].asset_ref doesn't carry
variant fields. Consumers calling r.assets.put or
r.project(id).apply({ assets: { put: [<image>] } }) saw an AssetRef
without variants/blurhash/width_px/etc. for first uploads — even though
the gateway DID generate them and bytes were live.
Fix: in applyOnce, after the commit succeeds and result.assets is
built, do a dry-run re-plan with the same spec if any put entry has an
image/* content_type. The recheck hits /apply/v1/plans?dry_run=true; the
gateway looks up internal.blob_image_variants by source_sha256, builds
an AssetImageData, threads it through buildAssetRefForPlan, and returns
asset_entries with the full variant shape. The SDK merges those fields
into the existing manifest entries.
Dry-run keeps the recheck cheap: no plan_id or operation_id rows are
created. The recheck is wrapped in try/catch so a failure can't break a
successful apply — variants stay empty rather than the apply throwing.
Also fixes a test assertion that compared display_url (wire mutable) to
the SDK's cdnUrl alias (wire immutable). Non-HEIC parity is:
ref.display_url === ref.cdnMutableUrl
ref.display_immutable_url === ref.cdnUrl
Both image-variant e2e tests now pass against api.run402.com.
Closes asset-image-variants-client tasks 9.1 / 9.2 strictly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0262011 commit 7e77b42
2 files changed
Lines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
767 | 767 | | |
768 | 768 | | |
769 | 769 | | |
770 | | - | |
771 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
772 | 775 | | |
773 | 776 | | |
774 | 777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
606 | 658 | | |
607 | 659 | | |
608 | 660 | | |
| |||
0 commit comments