feat(env-options): env-options conveniences for common cases#1710
Merged
feat(env-options): env-options conveniences for common cases#1710
Conversation
This was referenced Aug 2, 2023
dae87da to
f6190e7
Compare
b0abc60 to
11e8047
Compare
c8cbe6f to
e28ac45
Compare
Contributor
Author
|
See also nodejs/node#48890 |
8515a62 to
d692fac
Compare
2ce5dd0 to
a7664ac
Compare
695c347 to
7799061
Compare
7799061 to
77aea46
Compare
77aea46 to
7577a77
Compare
7577a77 to
1a0dd3e
Compare
7383ed9 to
e1199d3
Compare
e1199d3 to
30bd756
Compare
30bd756 to
59b523f
Compare
43ed48f to
19b3465
Compare
19b3465 to
c15595d
Compare
c15595d to
2f05b1a
Compare
This was referenced Jan 1, 2024
2f05b1a to
a8e1407
Compare
6926eb8 to
a802aa5
Compare
e130e8c to
ac480ad
Compare
michaelfig
approved these changes
Jan 10, 2024
gibson042
approved these changes
Jan 10, 2024
ac480ad to
c2dad51
Compare
erights
added a commit
that referenced
this pull request
May 13, 2025
Closes: #XXXX Refs: #1710 ## Description #1710 enhanced `getEnvironmentOption` with an optional third argument listing all the other allowed choices aside from the default choice. Previously, we had only manual code to detect and complain of unrecognized environment option values. #1710 provides a more declarative form, and reuses the checking-and-complaining logic. However, following #1710 we did not retire much of the previous ad-hoc manual code, nor did we make enough use of this declarative alternative. This PR fixes that. ### Security Considerations An advantage to the old ad-hoc manual style is that the enumeration of all possible alternatives was textually close to the dispatch on the alternative. This makes it easy to keep the two in sync. Thus, a comparative disadvantage of this PR is their separation, leading to maintenance hazards if one is updated but not the other. For example, if the declarative form adds another option that the dispatch code does not take into account, that other option might fall into the dispatch's fall-through case. This may or may not be good, depending on whether the fall through case is carefully chosen to also be appropriate for new not-previously-recognized options. ### Scaling Considerations none ### Documentation Considerations none ### Testing Considerations The text of the error messages for unrecognized options will likely be different. But aside from that there should be no observable difference. Since we do not consider a change to the text of an error message a correctness concern, we consider this PR to effectively be a pure refactor. ### Compatibility and Upgrade Considerations Both before and after this PR, we generally reject unrecognized environment options settings. This makes it difficult to grow existing options with new settings that are ignored if seen by previous code. This hinders plausible development patterns. This PR by itself does not change that. But by centralizing the detect-and-complaint logic and making it more declarative, perhaps we become better set up to address this issue later.
boneskull
pushed a commit
that referenced
this pull request
Jun 4, 2025
Closes: #XXXX Refs: #1710 ## Description #1710 enhanced `getEnvironmentOption` with an optional third argument listing all the other allowed choices aside from the default choice. Previously, we had only manual code to detect and complain of unrecognized environment option values. #1710 provides a more declarative form, and reuses the checking-and-complaining logic. However, following #1710 we did not retire much of the previous ad-hoc manual code, nor did we make enough use of this declarative alternative. This PR fixes that. ### Security Considerations An advantage to the old ad-hoc manual style is that the enumeration of all possible alternatives was textually close to the dispatch on the alternative. This makes it easy to keep the two in sync. Thus, a comparative disadvantage of this PR is their separation, leading to maintenance hazards if one is updated but not the other. For example, if the declarative form adds another option that the dispatch code does not take into account, that other option might fall into the dispatch's fall-through case. This may or may not be good, depending on whether the fall through case is carefully chosen to also be appropriate for new not-previously-recognized options. ### Scaling Considerations none ### Documentation Considerations none ### Testing Considerations The text of the error messages for unrecognized options will likely be different. But aside from that there should be no observable difference. Since we do not consider a change to the text of an error message a correctness concern, we consider this PR to effectively be a pure refactor. ### Compatibility and Upgrade Considerations Both before and after this PR, we generally reject unrecognized environment options settings. This makes it difficult to grow existing options with new settings that are ignored if seen by previous code. This hinders plausible development patterns. This PR by itself does not change that. But by centralizing the detect-and-complaint logic and making it more declarative, perhaps we become better set up to address this issue later.
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.
refs: Agoric/agoric-sdk#8136
refs: Agoric/agoric-sdk#8096
refs: https://github.com/Agoric/agoric-sdk/blob/master/docs/env.md#DEBUG
refs: #1922
The indirection of
getEnvironmentCaptoris only needed to supportgetCapturedEnvironmentOptionNamesgetCapturedEnvironmentOptionNamesis not currently used in eitherendooragoric-sdk. Thus, we have enhanced@endo/env/optionsto also directly export non-capturing forms of the other functions, likegetEnvironmentOption, that are made and returned bygetEnvironmentCaptor.The value of an option is often supposed to be a list of strings separated by commas (
','). HoweverAgoric/agoric-sdk#8096 explains that sometimes our code (both in endo and in agoric-sdk) accidentally split on colon (
':') instead due to confusion about what the convention was supposed to be.So that this PR would only be a compat
featPR, this PR does not fix any of those legacy manual uses that got the convention wrong. (Though it does add a TODO that links to Agoric/agoric-sdk#8096.) Rather,this PR does provide additional conveniences,
getEnvironmentOptionsListandenvironmentOptionsListHasbased on the correct comma option.Later PRs (#1922) that do take the compat hit of switching to comma should also switch to using these new conveniences.