Foundry's icons are not available: its bridge is not set up, or it cannot be reached right now. #74

Closed
opened 2026-10-15 16:11:31 +00:00 by Syndria98 · 6 comments
Owner

"Foundry's icons are not available: its bridge is not set up, or it cannot be reached right now." is displayed when it should work. The foundry service is open and operative and the campaign is connected. Can you fix it?

"Foundry's icons are not available: its bridge is not set up, or it cannot be reached right now." is displayed when it should work. The foundry service is open and operative and the campaign is connected. Can you fix it?
Syndria98 added the ai-ready label 2026-10-15 16:11:31 +00:00
Agent added the working label 2026-10-15 17:06:26 +00:00
Collaborator

I've traced the icon flow end-to-end and ran the read‑bridge + backend service locally against a sample icons/ tree. Let me record what I found before deciding, since the fix hinges on one point of missing information.

Key findings:

  • The icon browser (FoundryIconPickerWindow.vue) calls GET /api/foundry/icons, which backend/src/routes/foundry.js serves by calling requestFoundry('api/icons?...') → the read-only bridge (dragonroll-foundry/bridge/server.js), which lists the world's icons/ folder from disk via DRAGONROLL_FOUNDRY_DATA_PATH.
  • I verified that path works when configured: backend reaches the bridge and gets {status:'ok', dir, directories, files, next}.
  • Crucially, the campaign "connected / operative" state is a completely separate channel: the Foundry module syncs actors/items straight to the backend at /api/foundry/sync/* with the sync token. That does not touch the read bridge, and neither docker-compose.yml nor the deploy workflow runs the bridge, and FOUNDRY_API_URL/FOUNDRY_API_TOKEN aren't in the committed env. So a campaign can be fully connected and syncing while /api/foundry/icons returns 503 icons-unavailable because requestFoundry throws FOUNDRY_NOT_CONFIGURED (or the bridge has no DRAGONROLL_FOUNDRY_DATA_PATH).

The happy‑path code is correct; the symptom matches the read bridge not being configured/reachable, not a logic bug I can reproduce. The two real fixes diverge a lot, so I need one decision from the author before editing.

QUESTION: The icon browser works only through the optional read-only Foundry bridge (dragonroll-foundry/bridge, reading DRAGONROLL_FOUNDRY_DATA_PATH, reached by the backend via FOUNDRY_API_URL/FOUNDRY_API_TOKEN) — this is separate from the module→backend sync that proves a campaign is "connected", and it is not part of the standard deploy (docker-compose.yml/.env.production don't set it). Can you confirm the situation so I implement the right thing: (A) you DO run that bridge and want the backend pointed at it — in which case is the backend's FOUNDRY_API_URL/FOUNDRY_API_TOKEN set and is the bridge's DRAGONROLL_FOUNDRY_DATA_PATH pointed at the Foundry Data folder? (B) you do NOT want to run the read bridge — in which case I'll make the icon browser work from the already-connected Foundry module (module publishes its icons/ library to the backend, and /api/foundry/icons reads that instead of the bridge). Which do you want?

I've traced the icon flow end-to-end and ran the read‑bridge + backend service locally against a sample `icons/` tree. Let me record what I found before deciding, since the fix hinges on one point of missing information. Key findings: - The icon browser (`FoundryIconPickerWindow.vue`) calls `GET /api/foundry/icons`, which `backend/src/routes/foundry.js` serves by calling `requestFoundry('api/icons?...')` → the **read-only bridge** (`dragonroll-foundry/bridge/server.js`), which lists the world's `icons/` folder from disk via `DRAGONROLL_FOUNDRY_DATA_PATH`. - I verified that path works when configured: backend reaches the bridge and gets `{status:'ok', dir, directories, files, next}`. - Crucially, the **campaign "connected / operative" state is a completely separate channel**: the Foundry module syncs actors/items straight to the backend at `/api/foundry/sync/*` with the sync token. That does **not** touch the read bridge, and neither `docker-compose.yml` nor the deploy workflow runs the bridge, and `FOUNDRY_API_URL`/`FOUNDRY_API_TOKEN` aren't in the committed env. So a campaign can be fully connected and syncing while `/api/foundry/icons` returns 503 `icons-unavailable` because `requestFoundry` throws `FOUNDRY_NOT_CONFIGURED` (or the bridge has no `DRAGONROLL_FOUNDRY_DATA_PATH`). The happy‑path code is correct; the symptom matches the read bridge not being configured/reachable, not a logic bug I can reproduce. The two real fixes diverge a lot, so I need one decision from the author before editing. QUESTION: The icon browser works only through the optional read-only Foundry bridge (`dragonroll-foundry/bridge`, reading `DRAGONROLL_FOUNDRY_DATA_PATH`, reached by the backend via `FOUNDRY_API_URL`/`FOUNDRY_API_TOKEN`) — this is separate from the module→backend sync that proves a campaign is "connected", and it is not part of the standard deploy (`docker-compose.yml`/`.env.production` don't set it). Can you confirm the situation so I implement the right thing: (A) you DO run that bridge and want the backend pointed at it — in which case is the backend's `FOUNDRY_API_URL`/`FOUNDRY_API_TOKEN` set and is the bridge's `DRAGONROLL_FOUNDRY_DATA_PATH` pointed at the Foundry `Data` folder? (B) you do NOT want to run the read bridge — in which case I'll make the icon browser work from the already-connected Foundry module (module publishes its `icons/` library to the backend, and `/api/foundry/icons` reads that instead of the bridge). Which do you want?
Agent added help wanted and removed working labels 2026-10-15 17:36:58 +00:00
Author
Owner

Do option A, fetch the icons through the bridge, it seems cleaner

Do option A, fetch the icons through the bridge, it seems cleaner
Agent added the working label 2026-10-15 19:07:10 +00:00
Collaborator

The author confirmed option A (keep fetching icons through the bridge). Since I verified the bridge↔backend code path is correct when the bridge is reachable, the failure is the read side of the bridge not being reachable — and there is a concrete code inconsistency behind exactly this symptom: the write path resolves the bridge URL as FOUNDRY_API_CLIENT_URL || FOUNDRY_API_URL (service-link.js), while the read path used by the icon route (services/foundry.js) insists on FOUNDRY_API_URL alone. A world that connects and syncs fine can therefore still have the backend report "its bridge is not set up" for icons. A second, on-topic bug: the route returns non-200 codes, so axios throws and the window always shows the generic "bridge not set up" line, masking the real reason.

Let me implement both fixes.

The author confirmed **option A** (keep fetching icons through the bridge). Since I verified the bridge↔backend code path is correct when the bridge is reachable, the failure is the read side of the bridge not being reachable — and there is a concrete code inconsistency behind exactly this symptom: the *write* path resolves the bridge URL as `FOUNDRY_API_CLIENT_URL || FOUNDRY_API_URL` (`service-link.js`), while the *read* path used by the icon route (`services/foundry.js`) insists on `FOUNDRY_API_URL` alone. A world that connects and syncs fine can therefore still have the backend report "its bridge is not set up" for icons. A second, on-topic bug: the route returns non-200 codes, so axios throws and the window always shows the generic "bridge not set up" line, masking the real reason. Let me implement both fixes.
Collaborator

Now let me add tests. First the requires and helper:

Now let me add tests. First the requires and helper:
Collaborator

Done. Under option A (keep fetching icons through the bridge), I found and fixed a real inconsistency that produces exactly this symptom, plus the misleading error that made it impossible to tell what was wrong.

Root cause

The icon browser calls GET /api/foundry/icons, which the backend serves by reading the bridge (backend/src/services/foundry.js → requestFoundry). But the read side and the write side resolved the bridge differently:

  • Write / connect (routes/service-link.js) uses FOUNDRY_API_CLIENT_URL || FOUNDRY_API_URL — this is how the world connects and syncs, so the campaign shows "connected / operative".
  • Read (requestFoundry, used by the icons) used FOUNDRY_API_URL alone.

So a bridge configured under only FOUNDRY_API_CLIENT_URL (the address the Foundry client reaches) connected and synced perfectly while the icon read threw FOUNDRY_NOT_CONFIGURED → 503 icons-unavailable → "its bridge is not set up". Separately, the route returns non-2xx codes, and axios rejects those, so FoundryIconPickerWindow always showed the generic "bridge not set up" line and threw away the route's actual reason (e.g. "no Foundry world address").

Changes

  • backend/src/services/foundry.js — requestFoundry now resolves the base as FOUNDRY_API_URL || FOUNDRY_API_CLIENT_URL, mirroring the connect path, so the bridge a world already pushes to answers its icon reads too.
  • frontend/app/components/windows/FoundryIconPickerWindow.vue — the catch reads the backend's own message (requestError.response?.data?.msg) so it says what actually failed instead of always blaming the bridge.
  • tests/foundry-icon-picker.test.js — added functional tests: an icon read succeeds through a bridge reachable only under the client URL, an unconfigured bridge still reports FOUNDRY_NOT_CONFIGURED, and the window surfaces the real error. Full suite passes (node --test tests/): 253/253.

What option A still needs configured (this is the "set up the bridge" part)

Code can't list a directory that no process can read, so the read side of the bridge has to exist for the backend:

  1. Bridge (dragonroll-foundry/bridge/server.js) runs with DRAGONROLL_FOUNDRY_DATA_PATH pointed at the Foundry Data folder (the one containing icons/), and DRAGONROLL_FOUNDRY_READ_TOKEN set.
  2. Backend env: a bridge URL the backend can reach — FOUNDRY_API_URL (preferred) or FOUNDRY_API_CLIENT_URL (now also used for reads) — and FOUNDRY_API_TOKEN set to the bridge's DRAGONROLL_FOUNDRY_READ_TOKEN. The read token must be set: the bridge gates /api/icons on the read token, not the push token, so FOUNDRY_API_PUSH_TOKEN alone (enough to connect) is not enough to read.
FOUNDRY_API_URL='https://vtt.example.com/dragonroll-bridge/'   # backend→bridge
FOUNDRY_API_TOKEN='<same as the bridge DRAGONROLL_FOUNDRY_READ_TOKEN>'

With those set, a connected campaign's icon browser now loads folder-by-folder as designed; if something is still off (wrong data path, bridge down), the window now reports the specific reason instead of the one generic line.

Done. Under **option A** (keep fetching icons through the bridge), I found and fixed a real inconsistency that produces exactly this symptom, plus the misleading error that made it impossible to tell what was wrong. ## Root cause The icon browser calls `GET /api/foundry/icons`, which the backend serves by reading the bridge (`backend/src/services/foundry.js` → `requestFoundry`). But the read side and the write side resolved the bridge differently: - **Write / connect** (`routes/service-link.js`) uses `FOUNDRY_API_CLIENT_URL || FOUNDRY_API_URL` — this is how the world connects and syncs, so the campaign shows "connected / operative". - **Read** (`requestFoundry`, used by the icons) used `FOUNDRY_API_URL` **alone**. So a bridge configured under only `FOUNDRY_API_CLIENT_URL` (the address the Foundry client reaches) connected and synced perfectly while the icon read threw `FOUNDRY_NOT_CONFIGURED` → `503 icons-unavailable` → "its bridge is not set up". Separately, the route returns non-2xx codes, and axios rejects those, so `FoundryIconPickerWindow` always showed the generic "bridge not set up" line and threw away the route's actual reason (e.g. "no Foundry world address"). ## Changes - `backend/src/services/foundry.js` — `requestFoundry` now resolves the base as `FOUNDRY_API_URL || FOUNDRY_API_CLIENT_URL`, mirroring the connect path, so the bridge a world already pushes to answers its icon reads too. - `frontend/app/components/windows/FoundryIconPickerWindow.vue` — the `catch` reads the backend's own message (`requestError.response?.data?.msg`) so it says what actually failed instead of always blaming the bridge. - `tests/foundry-icon-picker.test.js` — added functional tests: an icon read succeeds through a bridge reachable only under the client URL, an unconfigured bridge still reports `FOUNDRY_NOT_CONFIGURED`, and the window surfaces the real error. Full suite passes (`node --test tests/`): **253/253**. ## What option A still needs configured (this is the "set up the bridge" part) Code can't list a directory that no process can read, so the read side of the bridge has to exist for the backend: 1. Bridge (`dragonroll-foundry/bridge/server.js`) runs with `DRAGONROLL_FOUNDRY_DATA_PATH` pointed at the Foundry **Data** folder (the one containing `icons/`), and `DRAGONROLL_FOUNDRY_READ_TOKEN` set. 2. Backend env: a bridge URL the backend can reach — `FOUNDRY_API_URL` (preferred) or `FOUNDRY_API_CLIENT_URL` (now also used for reads) — **and** `FOUNDRY_API_TOKEN` set to the bridge's `DRAGONROLL_FOUNDRY_READ_TOKEN`. The read token must be set: the bridge gates `/api/icons` on the read token, not the push token, so `FOUNDRY_API_PUSH_TOKEN` alone (enough to connect) is not enough to read. ```sh FOUNDRY_API_URL='https://vtt.example.com/dragonroll-bridge/' # backend→bridge FOUNDRY_API_TOKEN='<same as the bridge DRAGONROLL_FOUNDRY_READ_TOKEN>' ``` With those set, a connected campaign's icon browser now loads folder-by-folder as designed; if something is still off (wrong data path, bridge down), the window now reports the specific reason instead of the one generic line.
Collaborator

Implementation is ready for review: #82

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/82
Agent removed the working label 2026-10-15 19:24:19 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#74