Skip to content
Title:** IaC: typed references (
X.env.VAR
/
ref()
) show as changed on every plan when the target's name has a space
madsmhm
OP

2 hours ago

Problem and desired outcome

We manage our Railway projects with .railway/railway.ts and want to write cross-resource references with the SDK's typed form (BreeRedis.env.REDIS_URL) instead of hand-written ${{...}} strings. When the referenced service or database has a space in its name, railway config plan reports every such variable as changed, and it still does after an apply. The same references written as quoted strings plan clean. This is still happening; we currently work around it with a small helper that builds the quoted string from the resource's name, and we would like to drop it and use .env / ref() directly.

Resources and timing

  • Project: Skive Folkeblad - Silmarillion, ID 9c614716-254a-4aca-88b5-0cea80d6f4f4
  • Environment: development, ID 26849cf8-a269-4fec-a5ef-3a6278b3f1eb
  • Affected: 39 variables across the services in that environment (for example Bree DEV, Eriador SF, App Settings - SF, epaper-cron)
  • Observed on 2026-11-26 (CET). No deployment is failing; this is about the plan output.
  • Versions: Railway CLI 5.75.0, railway npm package 3.17.0 (railway/iac)

Evidence and attempts

Reproduction, with a database named Bree - Redis and a service Bree DEV that already has REDIS_URL stored as a reference to it:

const BreeRedis = redis("Bree -  Redis", { region: "europe-west4-drams3a" });

const BreeDEV = service("Bree DEV", {
  env: {
    // A: plans clean
    REDIS_URL: '${{"Bree -  Redis".REDIS_URL}}',
    // B: shows as changed on every plan
    // REDIS_URL: BreeRedis.env.REDIS_URL,
  },
});

With form B, railway config plan prints lines like these (two of the 39):

+ Update variable Bree DEV.REDIS_URL
  └ Bree DEV.REDIS_URL (preserve() → Bree -  Redis.REDIS_URL)
+ Update variable epaper-cron.BRAND_CONFIG_NAME
  └ epaper-cron.BRAND_CONFIG_NAME (preserve() → Boromir - SF DEV.BRAND_CONFIG_NAME)

What we did, in order:

  1. Converted 39 whole-value references in the environment from quoted strings (form A) to X.env.VAR (form B). Nothing else in the compiled configuration changed. The plan went from 7 changes to 46; the 39 new ones were exactly the converted variables.
  2. Ran railway config apply for that plan. Afterwards railway config plan reported Plan: 0 to add, 39 to change, 0 to destroy, the same 39 variables. The 7 unrelated changes were gone.
  3. Changed the 39 references back to quoted strings (built by a helper from the resource's name). railway config plan then reported "Your Railway configuration is already up to date."

For comparison, in another project (Gandalf, development) the referenced resources are named Postgres and Redis, with no spaces. There Postgres.env.DATABASE_URL, Redis.env.REDIS_URL and ref(Redis, "REDIS_PRIVATE_URL") plan clean, identical to the string form.

The same thing happens for service-to-service references (epaper-cron referencing Boromir - SF DEV), so it is not specific to databases.

Why contact support?

We decided to contact support ourselves, after confirming with an AI assistant's help that the behaviour is reproducible and not something we can fix in our own configuration. We would like Railway to check whether typed references to resources with spaces in their names are expected to plan clean, and if so to fix the mismatch, or to tell us the supported way to write them.

Uncertainty and constraints

Observed: the typed form produces a plan diff only when the target's name contains a space, and the diff persists after an apply.

Hypothesis, not confirmed: in the SDK's output the typed form is a structured reference (for example { type: "reference", resource: "service.Boromir - SF DEV", output: "BRAND_CONFIG_NAME" }). We assume it is later turned into ${{Boromir - SF DEV.BRAND_CONFIG_NAME}} without quotes, while Railway stores the reference with the name quoted (${{"Boromir - SF DEV".BRAND_CONFIG_NAME}}), and that the plan compares the two as text. This is based on the quoted string planning clean; we cannot read the stored raw value from the CLI. Our notes link this to railwayapp/cli#1329, which we believe covers unquoted string references; we have not confirmed it is the same cause.

Not known: whether the apply in step 2 actually wrote the 39 variables, and whether the services resolved the same values during that time. We have not checked the services for errors after the apply.

The plan shows the current value of these variables as preserve(), so the plan output does not tell us what Railway has stored for them.

No change to our resources is requested. Renaming the services and databases to remove spaces is not an option we want to take.

Awaiting Railway Response

0 Replies

Status changed to Awaiting Railway Response Railway • about 2 hours ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...