Foundry's icons are not available: its bridge is not set up, or it cannot be reached right now. #74
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
"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?
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:
FoundryIconPickerWindow.vue) callsGET /api/foundry/icons, whichbackend/src/routes/foundry.jsserves by callingrequestFoundry('api/icons?...')→ the read-only bridge (dragonroll-foundry/bridge/server.js), which lists the world'sicons/folder from disk viaDRAGONROLL_FOUNDRY_DATA_PATH.{status:'ok', dir, directories, files, next}./api/foundry/sync/*with the sync token. That does not touch the read bridge, and neitherdocker-compose.ymlnor the deploy workflow runs the bridge, andFOUNDRY_API_URL/FOUNDRY_API_TOKENaren't in the committed env. So a campaign can be fully connected and syncing while/api/foundry/iconsreturns 503icons-unavailablebecauserequestFoundrythrowsFOUNDRY_NOT_CONFIGURED(or the bridge has noDRAGONROLL_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, readingDRAGONROLL_FOUNDRY_DATA_PATH, reached by the backend viaFOUNDRY_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.productiondon'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'sFOUNDRY_API_URL/FOUNDRY_API_TOKENset and is the bridge'sDRAGONROLL_FOUNDRY_DATA_PATHpointed at the FoundryDatafolder? (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 itsicons/library to the backend, and/api/foundry/iconsreads that instead of the bridge). Which do you want?Do option A, fetch the icons through the bridge, it seems cleaner
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 onFOUNDRY_API_URLalone. 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.
Now let me add tests. First the requires and helper:
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:routes/service-link.js) usesFOUNDRY_API_CLIENT_URL || FOUNDRY_API_URL— this is how the world connects and syncs, so the campaign shows "connected / operative".requestFoundry, used by the icons) usedFOUNDRY_API_URLalone.So a bridge configured under only
FOUNDRY_API_CLIENT_URL(the address the Foundry client reaches) connected and synced perfectly while the icon read threwFOUNDRY_NOT_CONFIGURED→503 icons-unavailable→ "its bridge is not set up". Separately, the route returns non-2xx codes, and axios rejects those, soFoundryIconPickerWindowalways 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—requestFoundrynow resolves the base asFOUNDRY_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— thecatchreads 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 reportsFOUNDRY_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:
dragonroll-foundry/bridge/server.js) runs withDRAGONROLL_FOUNDRY_DATA_PATHpointed at the Foundry Data folder (the one containingicons/), andDRAGONROLL_FOUNDRY_READ_TOKENset.FOUNDRY_API_URL(preferred) orFOUNDRY_API_CLIENT_URL(now also used for reads) — andFOUNDRY_API_TOKENset to the bridge'sDRAGONROLL_FOUNDRY_READ_TOKEN. The read token must be set: the bridge gates/api/iconson the read token, not the push token, soFOUNDRY_API_PUSH_TOKENalone (enough to connect) is not enough to read.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.
Implementation is ready for review: #82