Skip to content

fix(client): infer cloud from API_URL+API_KEY when no STORAGE_MODE (fleet-flip)#17

Merged
andrei-hasna merged 1 commit into
mainfrom
fix/client-flip-infer-cloud-from-url-key
Jul 7, 2026
Merged

fix(client): infer cloud from API_URL+API_KEY when no STORAGE_MODE (fleet-flip)#17
andrei-hasna merged 1 commit into
mainfrom
fix/client-flip-infer-cloud-from-url-key

Conversation

@andrei-hasna

Copy link
Copy Markdown
Contributor

Root cause

The fleet env-flip (machines flip, see open-machines docs/FLEET-FLIP.md) writes exactly two vars per app and no HASNA_<APP>_STORAGE_MODE:

HASNA_<APP>_API_URL=https://<app>.hasna.xyz
HASNA_<APP>_API_KEY=<key>

But resolveClientTransport only switched to cloud when an explicit mode env was present. With url+key only, it fell through to local, so every app using the shared resolver (resolveStorageClient/createClientTransport) kept reading its on-box store after a flip — self_hosted was a silent no-op.

Proof (before): resolveClientTransport('todos', { HASNA_TODOS_API_URL, HASNA_TODOS_API_KEY }) => transport:'local'.

Fix

Infer mode=cloud from the joint presence of API_URL + API_KEY when no explicit mode env is set — mirroring the already-shipped vendored fix in open-projects/open-recordings (#22). Revert (removing both vars) returns to local. Explicit STORAGE_MODE=local still wins.

Cascades to all 9 direct-import apps: accounts, attachments, domains, files, logs, sandboxes, secrets, sessions, shortlinks, todos.

Tests

  • New: url+key-only => inferred cloud-http; revert (key removed) => local, not misconfigured.
  • Full suite green: 191 pass / 0 fail.

Version

0.5.0 -> 0.5.1 (CONTRACTS_PACKAGE_VERSION bumped to satisfy dist smoke).

…leet-flip)

The fleet env-flip writes exactly HASNA_<APP>_API_URL + HASNA_<APP>_API_KEY per
app and NO explicit STORAGE_MODE (machines FLEET-FLIP.md). resolveClientTransport
only switched to cloud on an explicit mode env, so every app using the shared
resolver (accounts, attachments, domains, files, logs, sandboxes, secrets,
sessions, shortlinks, todos) stayed on local and read its on-box store after a
flip. Infer mode=cloud from the joint presence of url+key, mirroring the vendored
projects/recordings client fix. Revert removes both vars -> back to local.

Bump 0.5.0 -> 0.5.1.
@andrei-hasna
andrei-hasna merged commit 0c8c5b4 into main Jul 7, 2026
1 check passed
@andrei-hasna
andrei-hasna deleted the fix/client-flip-infer-cloud-from-url-key branch July 7, 2026 10:02
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.

1 participant