2 hours ago
Have found an issue with IaC when deploying to environments other than the initial environment set up.
Setup: We manage one project with Railway IaC (.railway/railway.ts, railway npm package) and two environments, production and staging. In GitHub Actions we use railwayapp/config@v1 as in the IaC docs: PRs into main plan against staging, and merging applies that plan. PRs into production do the same for production. Each environment has its own project token as a repo secret.
Problem: the production token works. The staging plan always fails with:
Unauthorized. Please check that your RAILWAY_TOKEN is valid and has access to the resource you're trying to use.
What we’ve checked:
The staging project token is valid: query { projectToken { projectId environmentId } } returns the staging project and environment.
railway status with that token works and lists every staging service.
Locally, railway config plan, with or without --environment staging and with the directory unlinked, fails the same way. RAILWAY_VERBOSE=1 adds no detail.
Several freshly created staging project tokens all behave the same.
Same result with CLI 5.71 (in the action) and the latest CLI via npx @railway/cli@latest.
When can we expect a fix? we should be able to use IaC for different environments