{"record":{"id":"ebddf399d632e111","repo":"BigPizzaV3/CodexPlusPlus","slug":"getpackagesbypackagefamily-failed-with","errorCode":null,"errorMessage":"GetPackagesByPackageFamily failed with {}","messagePattern":"GetPackagesByPackageFamily failed with (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/app_paths.rs","lineNumber":160,"sourceCode":"        .encode_utf16()\n        .chain(std::iter::once(0))\n        .collect::<Vec<_>>();\n    let mut count = 0u32;\n    let mut buffer_length = 0u32;\n    let first = unsafe {\n        GetPackagesByPackageFamily(\n            PCWSTR(family.as_ptr()),\n            &mut count,\n            None,\n            &mut buffer_length,\n            PWSTR(std::ptr::null_mut()),\n        )\n    };\n    if first == APPMODEL_ERROR_NO_PACKAGE || (first == ERROR_SUCCESS && count == 0) {\n        return Ok(Vec::new());\n    }\n    if first != ERROR_INSUFFICIENT_BUFFER {\n        bail!(\"GetPackagesByPackageFamily failed with {}\", first.0);\n    }\n\n    let mut pointers = vec![PWSTR(std::ptr::null_mut()); count as usize];\n    let mut buffer = vec![0u16; buffer_length as usize];\n    let status = unsafe {\n        GetPackagesByPackageFamily(\n            PCWSTR(family.as_ptr()),\n            &mut count,\n            Some(pointers.as_mut_ptr()),\n            &mut buffer_length,\n            PWSTR(buffer.as_mut_ptr()),\n        )\n    };\n    if status != ERROR_SUCCESS {\n        bail!(\"GetPackagesByPackageFamily failed with {}\", status.0);\n    }\n    buffer.truncate(buffer_length as usize);\n    buffer","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/fb3ebd9a82383aedd8d098aa9ae3aef9426d13a4/crates/codex-plus-core/src/app_paths.rs#L142-L178","documentation":"Windows-only MSIX support in app_paths.rs enumerates packages for a package family via GetPackagesByPackageFamily using the two-call sizing pattern. The first call is made with a null buffer and must return ERROR_INSUFFICIENT_BUFFER (APPMODEL_ERROR_NO_PACKAGE or SUCCESS with count 0 are also accepted as 'no packages'). Any other Win32 status on this first call bails with the raw code number.","triggerScenarios":"The sizing call returns something other than ERROR_INSUFFICIENT_BUFFER: ERROR_INVALID_PARAMETER for a malformed family name (missing or wrong publisher-hash segment), ERROR_INSUFFICIENT_RESOURCES, or ERROR_SUCCESS with count > 0 (only count == 0 success is accepted).","commonSituations":"A hardcoded or derived package family name with a typo; running on Windows Server or a stripped image without full AppModel support; corrupted package registration where Get-AppxPackage still lists the app.","solutions":["Look up the numeric code from the message (map it with std::io::Error::from_raw_os_error) and check the family name being passed","Verify the family name shape Name_PublisherHash via PowerShell: Get-AppxPackage | Select PackageFamilyName","Confirm the package is registered for the current user with Get-AppxPackage <name>","If the status looks transient (resources/service), retry the enumeration once after a short delay"],"exampleFix":"// before\nif first != ERROR_INSUFFICIENT_BUFFER {\n    bail!(\"GetPackagesByPackageFamily failed with {}\", first.0);\n}\n\n// after - include the readable Win32 message for diagnosis\nif first != ERROR_INSUFFICIENT_BUFFER {\n    bail!(\n        \"GetPackagesByPackageFamily failed with {} ({})\",\n        first.0,\n        std::io::Error::from_raw_os_error(first.0 as i32)\n    );\n}","handlingStrategy":"fallback","validationCode":"// Validate family-name shape before calling the AppModel API\nfn valid_family_name(family: &str) -> bool {\n    let mut parts = family.splitn(2, '_');\n    matches!((parts.next(), parts.next()), (Some(n), Some(p)) if !n.is_empty() && !p.is_empty()\n        && family.chars().all(|c| c.is_ascii_alphanumeric() || c == '.' || c == '_' || c == '-'))\n}","typeGuard":null,"tryCatchPattern":"let packages = match package_full_names_by_family(&family) {\n    Ok(names) => names,\n    Err(error) => {\n        tracing::warn!(\"package enumeration failed ({error:#}); falling back to Program Files roots\");\n        windows_app_package_roots().into_iter().map(|root| root.join(app_folder)).collect()\n    }\n};","preventionTips":["Derive the family name from the app manifest at build time instead of hardcoding","Treat APPMODEL_ERROR_NO_PACKAGE as 'running unpackaged' and skip the packaged path","Map the raw code to std::io::Error when logging so the message is readable","Test on clean Windows VMs with and without the MSIX installed"],"tags":["windows","msix","win32","package-identity","ffi"],"backgroundTag":"win32-api-call-failed","analyzedSha":"fb3ebd9a82383aedd8d098aa9ae3aef9426d13a4","analyzedAt":"2026-08-17T11:35:12.031Z","contentChangedAt":"2026-08-17T11:35:12.031Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}