oxidecomputer / oxidecomputer/humility
"humility hiffy" should allow the user to provide clarity on ambiguous enums
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 584
- Forks
- 63
- Avg merge
- 3h
- Merged PRs (30d)
- 2
Description
The SP releases around 1.0.28/1.0.29 appear to contain two enums with the name SprotError. They're in different namespaces, obviously, but humility nonetheless must currently throw up its hands:
$ pfexec /tmp/humility hiffy -c SpRot.status
humility: attached to 0483:3754:003300324741500820383733 via ST-Link V3
humility hiffy failed: SprotError matches more than one enum: attest_data::messages::SprotError as GOFF 0x00039350 (object 21), drv_sprot_api::error::SprotError as GOFF 0x00044a4a (object 21)
$ /tmp/humility --version
humility 0.11.11
While it's true that the ultimate fix for this is likely to be more specific in the idol file in Hubris itself, that doesn't help folks trying to get by with images that have already been built and are in use. We could provide a way for the user to provide clarity when possible; e.g., an environment variable override might look like:
$ HIFFY_PHRASEBOOK='SprotError=drv_sprot_api::error::SprotError' pfexec /tmp/humility hiffy -c SpRot.status
humility: attached to 0483:3754:003300324741500820383733 via ST-Link V3
SpRot.status() => Err(<Complex error: SprotError>)
$ echo $?
0
diff --git a/humility-core/src/hubris.rs b/humility-core/src/hubris.rs
index 5664e4e2..e2ca445b 100644
--- a/humility-core/src/hubris.rs
+++ b/humility-core/src/hubris.rs
@@ -6445,6 +6445,46 @@ impl HubrisModule {
.dedup(v.iter().filter(|g| g.object == self.object))?;
if m.len() > 1 {
+ /*
+ * Allow the user to provide more specific type names by
+ * passing a comma separated list of mappings like
+ * "ShortName=long::name::ShortName" in the HIFFY_PHRASEBOOK
+ * environment variable.
+ */
+ if let Ok(pb) = std::env::var("HIFFY_PHRASEBOOK") {
+ for t in pb.split(',') {
+ if let Some((k, v)) = t.split_once('=') {
+ if k == name {
+ /*
+ * We have a phrase book entry for this
+ * name! Check the filtered results to
+ * see if there is a single match:
+ */
+ let m = m.iter().find(|g| {
+ let ge = hubris.enums.get(g).unwrap();
+
+ if let Ok(Some(name)) =
+ hubris.namespaces.to_full_name(
+ ge.namespace,
+ &name.to_string(),
+ )
+ {
+ name == v
+ } else {
+ false
+ }
+ });
+
+ if let Some(m) = m {
+ return Ok(Some(
+ hubris.enums.get(&m).unwrap(),
+ ));
+ }
+ }
+ }
+ }
+ }
+
let all = m
.iter()
.map(|g| {
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in humility-core/src/hubris.rs, in HubrisModule's ambiguous enum resolution used by the hiffy command, and read how candidate enum names are filtered. Implement the requested HIFFY_PHRASEBOOK disambiguation behavior and verify that a matching fully qualified name selects the enum while unresolved ambiguity still reports an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100