Skip to content

fix: keep order/cart address copies live until frozen - #196

Merged
sveneberth merged 3 commits into
viur-framework:mainfrom
sveneberth:fix/live-address-relation-until-frozen
Jul 31, 2026
Merged

fix: keep order/cart address copies live until frozen#196
sveneberth merged 3 commits into
viur-framework:mainfrom
sveneberth:fix/live-address-relation-until-frozen

Conversation

@sveneberth

Copy link
Copy Markdown
Member

Summary

OrderSkel.billing_address and CartNodeSkel.shipping_address persist the referenced address as a copy (refKeys="*"). Since #179 they use updateLevel=OnValueAssignment, which freezes that copy already at assignment time — so any edit to the address during an ongoing checkout (adding a birthdate in a later step, correcting the address) was never mirrored onto the order/cart. OnValueAssignment additionally turned the existing refresh_billing_address / refresh_shipping_address helpers into silent no-ops.

Fix

New SnapshotRelationalBone:

  • configured with updateLevel=Always, so the copy is kept in sync — both by the update_relations task (target edited) and by explicit refresh() calls — while the owning skeleton is still editable;
  • overrides refresh() to a no-op once the owning skeleton is frozen, preserving the snapshot captured at freeze time.

The freeze predicate is configurable: is_ordered for OrderSkel.billing_address, and the default is_frozen for CartNodeSkel.shipping_address.

Also guards refresh_shipping_address against sub-node skeletons that don't carry the shipping_address bone (previously raised AttributeError on every cart read of such a node).

Trade-off

While a skeleton is frozen, editing a referenced address still triggers the update_relations task (the relation is serialized as Always) and re-writes the referencing order/cart once — but refresh() is a no-op there, so the persisted snapshot stays unchanged. Avoiding that extra write would require a dynamic serialized updateLevel, which is out of scope here.

Test plan

  • Unit: updateLevel is forced to Always; refresh() runs while open and no-ops while frozen (both is_ordered and is_frozen predicates).
  • Dev server boots and serves with the change; full checkout re-verified manually — a birthdate added in a later step now propagates to the still-open order, and a frozen/completed order is no longer changed by later address edits.

`OrderSkel.billing_address` and `CartNodeSkel.shipping_address` used
`updateLevel=OnValueAssignment` to persist the address as a copy, but that
froze the copy already at assignment time: edits made to the referenced
address during an ongoing checkout (adding a birthdate in a later step,
correcting the address) were never mirrored onto the order/cart, and
`OnValueAssignment` additionally turned the existing `refresh_*` helpers
into no-ops.

Add `SnapshotRelationalBone`, which keeps the copy in sync (like `Always`)
while the owning skeleton is editable and freezes it via a `refresh()`
no-op once the skeleton is frozen (`is_ordered` for the order, `is_frozen`
for the cart). This preserves the snapshot for completed orders while
reflecting live edits until checkout completes.

Also guard `refresh_shipping_address` against sub-node skeletons that
don't carry the `shipping_address` bone.
Copilot AI review requested due to automatic review settings July 29, 2026 18:11
@sveneberth sveneberth added bug(fix) Something isn't working or address a specific issue or vulnerability component: skeleton python Pull requests that update python code labels Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sveneberth
sveneberth changed the base branch from develop to main July 29, 2026 18:15
@sveneberth sveneberth added the Priority: Critical This should be dealt with ASAP. It's blocking someone. label Jul 29, 2026
Comment thread src/viur/shop/skeletons/_bones.py Outdated
sveneberth and others added 2 commits July 30, 2026 01:06
@sveneberth
sveneberth requested a review from phorward July 29, 2026 23:11
@sveneberth
sveneberth merged commit 7dc9e1c into viur-framework:main Jul 31, 2026
1 check passed
@sveneberth
sveneberth deleted the fix/live-address-relation-until-frozen branch July 31, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug(fix) Something isn't working or address a specific issue or vulnerability component: skeleton Priority: Critical This should be dealt with ASAP. It's blocking someone. python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants