{"record":{"id":"14d6f10978860103","repo":"AprilNEA/OpenLogi","slug":"fixture-identity-policy-returned-the-wrong-representation","errorCode":null,"errorMessage":"fixture identity policy returned the wrong representation","messagePattern":"fixture identity policy returned the wrong representation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/fixture/record_profile/sanitize.rs","lineNumber":67,"sourceCode":"    }\n    Ok(())\n}\n\nfn ordinal(index: usize) -> Result<SyntheticIdentityOrdinal> {\n    let value = u16::try_from(index.saturating_add(1))\n        .map_err(|_| anyhow!(\"captured profile has too many identities to sanitize\"))?;\n    SyntheticIdentityOrdinal::new(value)\n        .map_err(|_| anyhow!(\"captured profile has too many identities to sanitize\"))\n}\n\nfn profile_identity(\n    kind: SyntheticIdentityKind,\n    ordinal: SyntheticIdentityOrdinal,\n) -> Result<String> {\n    generate_synthetic_identity(kind, ordinal)\n        .as_profile_str()\n        .map(str::to_string)\n        .ok_or_else(|| anyhow!(\"fixture identity policy returned the wrong representation\"))\n}\n\nfn unit_id(ordinal: SyntheticIdentityOrdinal) -> Result<[u8; 4]> {\n    match generate_synthetic_identity(SyntheticIdentityKind::DeviceUnitId, ordinal) {\n        SyntheticIdentityValue::DeviceUnitId(value) => Ok(value),\n        _ => Err(anyhow!(\n            \"fixture identity policy returned the wrong representation\"\n        )),\n    }\n}\n","sourceCodeStart":49,"sourceCodeEnd":78,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/fixture/record_profile/sanitize.rs#L49-L78","documentation":"Thrown by `profile_identity()` when `generate_synthetic_identity` returns a value that is not the profile-string representation expected for the requested kind. `as_profile_str()` yields None, meaning the fixture identity policy produced a variant the caller did not anticipate. This is an internal invariant check between openlogi-cli and the openlogi-fixture policy API.","triggerScenarios":"Calling `generate_synthetic_identity(kind, ordinal)` and calling `.as_profile_str()` when the policy returns a non-string-backed variant for that kind — e.g. a kind like DeviceUnitId that maps to raw bytes instead of a display/profile string.","commonSituations":"A new SyntheticIdentityKind added to openlogi-fixture without a string profile representation; a refactor of the policy enum that changed which kinds are string-backed; mismatched crate versions where the CLI assumes old policy semantics.","solutions":["Ensure the `kind` passed in is a string-backed identity kind; route byte-valued kinds (e.g. DeviceUnitId) through their dedicated accessors like `unit_id()`","Update openlogi-fixture so every kind used by `profile_identity` implements `as_profile_str()`","Re-sync openlogi-cli with the current openlogi-fixture API after a dependency upgrade"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if !matches!(kind, SyntheticIdentityKind::DisplayName | SyntheticIdentityKind::ProfileString) {\n    return Err(anyhow!(\"kind {} is not string-backed\", kind as u8));\n}","typeGuard":"fn string_backed(v: &SyntheticIdentityValue) -> Option<String> {\n    v.as_profile_str().map(str::to_string)\n}","tryCatchPattern":"let id = generate_synthetic_identity(kind, ordinal);\nif let Some(s) = id.as_profile_str() {\n    Ok(s.to_string())\n} else {\n    Err(anyhow!(\"kind {:?} has no profile-string form\", kind))\n}","preventionTips":["Route each identity kind through its matching accessor (string kinds via profile_identity, byte kinds via unit_id)","Add exhaustive match tests over SyntheticIdentityKind in openlogi-fixture","Keep openlogi-cli and openlogi-fixture in the same workspace lockstep"],"tags":["rust","fixture","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8","analyzedAt":"2026-09-13T03:07:16.451Z","contentChangedAt":"2026-09-13T03:07:16.451Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}