fix(add): don't fail after service creation when project context is env-injected#1015
Open
coffee-cup wants to merge 2 commits into
Open
fix(add): don't fail after service creation when project context is env-injected#1015coffee-cup wants to merge 2 commits into
coffee-cup wants to merge 2 commits into
Conversation
…nv-injected
railway add resolved RAILWAY_PROJECT_ID/RAILWAY_ENVIRONMENT_ID for the
serviceCreate mutation, then errored in link_service because there is no
on-disk link entry to update in that mode. The service was created but the
CLI exited nonzero without ever printing the new service id, so callers
(CI, cloud agents) treated creation as failed and picked wrong targets.
- add: print the created {id, name} before local-link bookkeeping and skip
linking entirely under env-var/token targeting
- deploy fetch_and_create: same skip for the post-create auto-link
- config: name the predicate (uses_env_project_targeting) and reuse it in
get_closest_linked_project_directory
Claude-Session: https://claude.ai/code/session_01LPDihPsFce5vyxdbNGvV8S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Inside a Railway Cloud Agent VM (or any env with
RAILWAY_PROJECT_ID/RAILWAY_ENVIRONMENT_ID/RAILWAY_TOKENtargeting and no on-disk link),railway add --service <name>:serviceCreatemutation succeeds — the service exists now ✓configs.link_service()→get_linked_project_mut()only reads the on-disk~/.railwayconfig, finds no entry for cwd →Project not found. Run railway link✗{id, name}Callers (CI scripts, cloud agents) see a failure, never learn the new service id, and improvise — in the observed case, an agent deployed to a preexisting service instead of the one it had just created.
Fix
add: report the created service (JSON / spinner) before local-link bookkeeping, and skip linking entirely when project targeting is env-injected — there is no on-disk entry to update. Spinner only claims "and linked to it" when it actually links.deployfetch_and_create(used byrailway add --databaseand template deploys): same shape, same skip for the post-create auto-link.config: name the predicateuses_env_project_targeting()and reuse it inget_closest_linked_project_directory, which already special-cased the identical condition.up.rs's post-createlink_serviceis safe as-is: that flow disk-links the project vialink_projectbefore linking the service.Verification
cargo test: 451 passedcargo clippy --all-targets: same 44 pre-existing warnings as master, none new