Skip to content

fix(store): generate a unique id per Store instance#25

Merged
Az107 merged 1 commit into
Az107:developfrom
LoboGuardian:fix/store-default-id
Jul 5, 2026
Merged

fix(store): generate a unique id per Store instance#25
Az107 merged 1 commit into
Az107:developfrom
LoboGuardian:fix/store-default-id

Conversation

@LoboGuardian

Copy link
Copy Markdown
Collaborator

Problem

Store.__init__ defaults id to str(uuid4()):

def __init__(self, default={}, subscribe=True, id=str(uuid4())):

Default arguments are evaluated once, at import time, so every Store created without an explicit id receives the same UUID. Each then registers under that same key in SuperStore.stores (add() overwrites), so two independent default-constructed stores collapse into one endpoint — /api/_store/{id}/* traffic for store A is served by whichever store registered last.

Fix

Default id=None and generate the UUID inside __init__:

def __init__(self, default={}, subscribe=True, id=None):
    self._id = id if id is not None else str(uuid4())

Verification

a, b = Store(), Store()   -> a._id != b._id   ✓
Store(id="x")._id == "x"                        ✓

No API change; explicit ids still honored (incl. AuthStore, which passes id=self._id).

The `id` parameter defaulted to `str(uuid4())`, a default argument
evaluated once at import time, so every Store created without an explicit
id shared the same UUID and overwrote the previous one in SuperStore —
routing all their /api/_store/{id}/* traffic to whichever registered
last. Default to None and generate the UUID inside __init__ so each
instance gets its own id.
@Az107

Az107 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

LGTM.
Setting base branch to develop

@Az107 Az107 changed the base branch from main to develop July 5, 2026 14:04
@Az107 Az107 merged commit 7cfd262 into Az107:develop Jul 5, 2026
LoboGuardian added a commit to LoboGuardian/HTeaLeaf that referenced this pull request Jul 11, 2026
The develop branch renamed the package to lowercase htealeaf, exports
the app class as HteaLeaf (the htealeaf factory alias is gone), removed
enable_reactivity in favour of SuperStore(app) wiring, and dropped
Store.react() — stores are now read server-side with .read() and the
client re-renders via DOM reconciliation. Store ids are auto-generated
per instance since Az107#25, so the explicit id workaround is unnecessary.
Also marks async-first architecture done in the roadmap and notes the
session TTL work on feature/alb-28.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants