commit | daed00e76b6cd4a97a10c95df4ba6750e37ba1bf | [log] [tgz] |
---|---|---|
author | Steven Grady <slgrady@google.com> | Fri Dec 20 13:58:00 2024 -0800 |
committer | CQ Bot <fuchsia-internal-scoped@luci-project-accounts.iam.gserviceaccount.com> | Fri Dec 20 13:58:00 2024 -0800 |
tree | 90db8866b3b4cda68b18ebf5680565cf61f3e68b | |
parent | 99289f071c3968d3d3fca59783ef09fdda7dd956 [diff] |
[ffx] Fix strict handling of env vars in config When in strict mode, we need to reject env vars. But rather than just not doing the env_var mapping, which would leave the strings as "$ENV_VAR" which is never what we want. It would cause problems like failing to find separately-built tools, or failing to find the SDK path, without providing a useful error message. Instead, we should actionable error to the user, reporting the name of the config variable that failed, and show them the string that failed to be map. This requires some surgery to config: e.g. getting away from the type magic involved in TryFrom (and its associated error type). Instead, there is now a TryConvert trait which always returns ConfigError. There is also a new member of the ConfigError enum, BadValue, which is only returned (currently) when in strict mode. It contains a useful description of why the conversion failed. This error was introduced because it can carry information about why the failure occurred, but it also lets a caller determine whether they care whether it failed. In some cases (e.g. in get_target_specifier()) we can just ignore it and assume the value is None. There is now a convenience function, get_optional(), which the caller can use when it doesn't care about this particular error. Fixed: 383636241 Fixed: 382333204 Change-Id: Ica197d41f92d44d96b40c898795b4b7d20bcb758 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1177196 Commit-Queue: Steven Grady <slgrady@google.com> Reviewed-by: Colin Nelson <colnnelson@google.com>
Fuchsia is an open source, general purpose operating system supporting modern 64-bit Intel and ARM processors.
We expect everyone interacting with our project to respect our code of conduct.
Read more about Fuchsia's principles.
See Getting Started.
See fuchsia.dev.