fix(environment): prioritize --service-config flags over auto-detected stdin in get_edit_config - #1045
Open
AmariahAK wants to merge 1 commit into
Open
fix(environment): prioritize --service-config flags over auto-detected stdin in get_edit_config#1045AmariahAK wants to merge 1 commit into
AmariahAK wants to merge 1 commit into
Conversation
…t_edit_config Explicit --service-config and --service-variable flags now take priority over the stdin auto-detection path, so non-TTY environments (scripts, CI) that pass flags plus empty/redirected stdin no longer silently discard them. Also print 'No changes to apply' to stderr in non-TTY non-JSON mode so scripted callers can detect the no-op instead of getting silence. Fixes railwayapp#1044 Co-authored-by: atlarix-agent <agent@atlarix.dev>
Author
|
@codyde — could you add the release/patch label to this PR? I don't have permission as a fork contributor. Thanks! |
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.
Description
What was the issue?
railway environment edit --service-config <SERVICE> <PATH> <VALUE>silently discards the--service-configflags and exits0whenever stdin is not a TTY (scripts, CI, agent harnesses, or< /dev/null). No changes are committed, and in the default output mode nothing is printed — the command appears to succeed but does nothing.Where was the issue?
src/commands/environment/edit.rs— theget_edit_configfunction checked!stdin_is_terminalbeforehas_cli_flags. When stdin was non-TTY (even empty), it short-circuited intoread_config_from_stdin, which returned an emptyEnvironmentConfig::default(). The explicitly passed CLI flags were never reached.Additionally, the empty-config early-return only printed
"No changes to apply"when--jsonor an interactive TTY was active. Non-TTY, non-JSON callers got silence and exit code0.How was it fixed?
Two changes in
get_edit_config:has_cli_flags(explicit--service-config/--service-variableflags) to Priority 1, above the!stdin_is_terminalauto-detection block. Explicit user intent always wins over environment detection.eprintln!fallback — when the resulting config is empty and neither--jsonnor an interactive TTY is active,"No changes to apply"now prints to stderr so scripted callers can detect the no-op.Why this approach?
--service-configmeant to use it — the absence of a TTY shouldn't override that.edit_services_selectinnew.rsalready checks CLI flags first, then terminal state.get_edit_configwas the outlier.How to test locally
Fixes #1044
Original issue: #1044