Skip to content

A rebuilt sandbox comes up with its shop, and keeps what was configured - #648

Merged
sridharkalaibala merged 1 commit into
developfrom
fix/a-rebuilt-sandbox-keeps-its-shop
Sep 13, 2026
Merged

sridharkalaibala merged 1 commit into
developfrom
fix/a-rebuilt-sandbox-keeps-its-shop

Conversation

@sridharkalaibala

Copy link
Copy Markdown
Contributor

Owner: "Live voice is switched off for this shop ... i didnt do. may be db reset?" and "open ai setting gone."

He was right, and yesterday's keep did not save him. Today's reset fell through two holes at once.

One: the seeder never set up online ordering

The box did not restore its snapshot, it rebuilt from seed.js — and seed.js has never configured online ordering. Right now:

GET https://develop.posnic.io/online-ordering
{"type":"error","message":"This shop is not taking online orders yet.","data":{"reason":"none_configured"}}

No store address, so /order/ABC is gone and every printed code points at nothing. Every rebuild has always done this; it went unnoticed because the nightly reset usually restores a snapshot where the address had been set by hand.

The seeder now switches ordering on, at a fixed address (SEED_STORE_ADDRESS, default ABC) rather than a generated one. An address that changes on each rebuild breaks every QR code and every pasted link — which is what happened when it went ABC123, then FJ5AF, then ABC. It will not stamp over a shop that already has one.

Two: the keep could not re-home what it saved

The keep dumps branch_secrets and branch_preferences and puts them back, but their rows are keyed by licence and branch id. A rebuild mints new ones, so the restored rows pointed at a branch that no longer existed, and the shop read as though nothing had ever been configured. The keep worked for a restore and did nothing for a rebuild — the exact case it was added for.

keep-branches.js now handles both. A restore lands the ordinary way. When the old branch is gone and there is exactly one shop now, the ordering configuration and the settings rows are re-homed onto it, so a key typed yesterday is still a key today. One shop is not a guess; several would be, and then it does nothing and says so. An account row belongs to the licence rather than a branch, so it takes the new licence and keeps its null branch.

Tests

tests/sandbox-scripts-deployed.test.js (7 now): the seeder configures ordering at a fixed address and will not overwrite an existing one; the keep re-homes both collections, treats account rows correctly, refuses to guess when there is more than one shop, still handles the restore case, and cleans up its working copy.

After this deploys

The next reset brings the shop back at /order/ABC with whatever is configured at that moment. This does not restore what today's rebuild already lost — the key and the switches will need entering once more, and then they stay.

Owner: "Live voice is switched off for this shop ... i didnt do. may be db
reset?" and "open ai setting gone."

He was right, and yesterday's keep did not save him. Today's reset fell
through two holes at once.

The box did not RESTORE its snapshot, it REBUILT from the seeder - and the
seeder has never configured online ordering at all. So it came up with no
store address: /online-ordering answers "none_configured" and every printed
code points at nothing. Every rebuild has always done this; nobody noticed
because the snapshot usually restores instead. The seeder now switches
ordering on, at a FIXED address rather than a generated one, because an
address that changes on every rebuild breaks every QR code and every link
anybody has pasted - which is exactly what happened when it went ABC123,
then FJ5AF, then ABC.

And the keep saves the settings collections faithfully, but their rows are
keyed by licence and branch id. A rebuild mints new ones, so the restored
rows pointed at a branch that no longer existed and the shop read as though
nothing had ever been configured: no key, no switches, no address. The keep
worked for a restore and did nothing for a rebuild, which is the case that
needed it. When the old branch is gone and there is exactly one shop now,
the configuration and the settings rows are re-homed onto it. One shop is
not a guess; several would be, and then it does nothing and says so rather
than picking.

An account row belongs to the licence rather than to a branch, so it takes
the new licence and keeps its null branch.
@sridharkalaibala
sridharkalaibala merged commit 3bb95fd into develop Sep 13, 2026
9 checks passed
@github-actions github-actions Bot added the ready for QA Merged to develop and live on develop.posnic.io - anyone can test it label Sep 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Merged to develop. Anyone can test this - you do not need write access.

Try it at https://develop.posnic.io, or run it yourself:

git fetch origin develop && git checkout develop
npm install && npm --prefix api install
npm run dev   # then http://localhost:3000

When you have tested it, say what you did and what happened, and set
QA passed or QA failed. If you cannot set labels, just comment -
a maintainer will.

Reporting that something is broken is as useful as fixing it. It is
better found here than by a shopkeeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for QA Merged to develop and live on develop.posnic.io - anyone can test it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant