Bucket-in-template deploys: reference variables resolve to empty strings when the service is created before the bucket
hmseeb
PROOP

15 days ago

When deploying a template that bundles a Storage Bucket, the service's first deployment frequently bakes its environment before the bucket finishes provisioning. Bucket reference variables like ${{my-bucket.BUCKET}} and ${{my-bucket.ACCESS_KEY_ID}} resolve to EMPTY strings, and container restarts never re-resolve them - only a manual Redeploy does. A variable defined as s3://${{my-bucket.BUCKET}} reaches the container as literal 's3://'. The deployment still shows SUCCESS while the app crash-loops on missing credentials.

Repro: deployed my bucket-bundling marketplace template 5 times on 2026-08-06 - 4 of 5 deploys hit this, including one via the marketplace deploy button in the dashboard (not just templateDeployV2 via the API). The changelog for Buckets in Templates (2025-11-07) says Railway will provision the bucket automatically and wire up credentials to services - the official example template public-bucket-image-proxy uses the same wiring and appears to have the same exposure.

Workaround: one manual Redeploy fixes it. Suggested fixes: block template service deployment on bundled bucket readiness, or auto-redeploy services whose bucket references baked empty, or at minimum fail the deployment loudly instead of injecting empty strings into a SUCCESS deploy.

Solved

6 Replies

Railway
BOT

15 days ago

The documented deployment dependency ordering gates service startup on other services' reference variables being ready, but it does not explicitly cover bucket provisioning timing during template deploys. When a service's reference variables (e.g. ${{my-bucket.BUCKET}}) resolve before the bucket finishes provisioning, they bake as empty strings, and restarts do not re-resolve them since the variables were already injected at deploy time. A manual redeploy after the bucket is ready is the correct workaround, as it forces a fresh variable resolution pass. Your suggestions for improving this behavior (blocking on bucket readiness, auto-redeploying, or failing loudly on empty references) are solid feature feedback worth posting to Central Station so the team can track demand.


Status changed to Awaiting User Response Railway 15 days ago


hmseeb
PROOP

15 days ago

Follow-up with a deeper diagnosis after more testing. The empty value is not a deploy-time bake: it is cached per-variable at variable CREATION time. Evidence: on an affected project, the bucket exists and issues credentials fine, but ${{bucket.X}} references resolve empty persistently. Re-writing a variable (variableUpsert with the same value) immediately fixes THAT variable only; untouched sibling variables stay empty. So the documented workaround needs correcting: a plain Redeploy does NOT heal it - you must re-save each affected variable, then redeploy. Also tested the deployment-dependencies ordering workaround (service referencing a sleep-and-exit service to delay startup past bucket provisioning): 0/3 improvement, consistent with creation-time caching. Total repro across today: 7 of 8 template deploys affected. Hope this narrows it down - looks like the template workflow creates service variables before bucket registration completes, and the resolver caches the miss.


Status changed to Awaiting Railway Response Railway 15 days ago


chandrika
EMPLOYEE

15 days ago

Correction to our earlier reply: a plain redeploy alone does not fix this, as you demonstrated. The per-variable re-save (then redeploy) workaround you found is the right one for now. The deployment dependency ordering documented here covers service-to-service references, not bucket provisioning, which is why the sleep-and-exit delay had no effect either. I've shared this with the team to look into, but can't promise a timeline on the fix


Status changed to Awaiting User Response Railway 15 days ago


chandrika
EMPLOYEE

13 days ago

Hey Hasseeb! Good news, we tracked this down and shipped a change off the back of your report 🙌

It wasn't a provisioning race. Your celld template's service variables point at a bucket namespace that doesn't exist. They reference a UUID left over from an earlier version of the template, while the bucket actually bundled with it is named celld-cells. Nothing on the deployed project matches that namespace, so it renders as an empty string on every deploy, permanently.

That also explains the behavior you mapped out. A redeploy can't heal it because there is nothing to resolve to, and re-saving a variable does fix that one variable because saving from the dashboard rewrites the reference to the live bucket. Your "re-save fixes THAT variable only" finding is what pinned it down, so thank you for the extra round of testing.

To fix it for good: update the bucket references in your template's service variables to use the bucket's name, so s3://${{celld-cells.BUCKET}}, ${{celld-cells.ACCESS_KEY_ID}} and so on, then re-publish the template. New deploys will wire up correctly on first boot. For projects already deployed from the old version, the per-variable re-save you found is still the way to recover them.


chandrika
EMPLOYEE

13 days ago

We also took your "fail loudly" suggestion! Paulo (on-call this week) shipped a change so that publishing a template whose variable references can't resolve now fails with an error naming the exact variables, instead of quietly handing every deployer a broken project.

Let us know if anything still comes up empty after you re-publish and we'll be happy to dig back in.

Happy building 🚂!


Status changed to Solved chandrika 13 days ago


hmseeb
PROOP

13 days ago

Confirmed on my end. Updated the template's variables to name-based refs (${{celld-cells.*}}) and re-published; a fresh deploy now wires up correctly on first boot, self-seed and all. You were right that my race theory was wrong, the stale UUID explains every symptom I measured. Thanks for digging past the first answer, and glad the fail-loudly publish check shipped. Happy building 🚂


Status changed to Awaiting Railway Response Railway 13 days ago


Status changed to Solved Railway 13 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...