Validate Railway deploy config - #643
Conversation
Greptile SummaryThis PR adds upfront validation to the Railway deployment target, requiring non-empty
Confidence Score: 4/5The new validation logic is correct and tests exercise all rejection paths; two small stale fragments left over from the pre-normalization version make the code slightly misleading but do not affect runtime behavior. The normalization block in ship() works correctly end-to-end, and the new tests confirm it. Two leftovers from before the refactor — a dead ?? fallback for env and always-truthy if (config.serviceId) / if (env) guards — are unreachable but create a false impression that the environment could still be undefined or the service flag could be skipped after validation passes. packages/targets/deploy-railway/src/index.ts — lines 49 and 59–60 carry dead code that should be cleaned up before merging. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[ship called] --> B[requireSegment projectId]
B -->|blank or invalid chars| ERR1[throw: requires projectId / must be single path segment]
B --> C[requireSegment serviceId]
C -->|blank or invalid chars| ERR2[throw: requires serviceId / must be single path segment]
C --> D[environmentName]
D -->|environment blank| ERR3[throw: requires environment]
D -->|environment invalid chars| ERR4[throw: must contain only letters...]
D -->|environment undefined| DEFAULT[default to production or staging based on channel]
D --> E[config normalized]
DEFAULT --> E
E --> F{dryRun?}
F -->|yes| G[return id: dry-run]
F -->|no| H{RAILWAY_TOKEN set?}
H -->|no| ERR5[throw: RAILWAY_TOKEN required]
H -->|yes| I[exec railway up --ci --service --environment]
I --> J[return id + meta]
|
| serviceId: requireSegment(config.serviceId, 'serviceId'), | ||
| environment: environmentName(config, ctx.channel), | ||
| }; | ||
| const env = config.environment ?? (ctx.channel === 'stable' ? 'production' : 'staging'); |
There was a problem hiding this comment.
The
?? fallback for env can never execute. environmentName() is called on line 47 and always either throws or returns a non-empty string, so config.environment is guaranteed to be a non-empty string by the time line 49 runs — the null-coalescing branch is dead code left over from before the normalization block was introduced.
| const env = config.environment ?? (ctx.channel === 'stable' ? 'production' : 'staging'); | |
| const env = config.environment!; |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
11 similar comments
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Fixes #642.
Changes:
Validation: