{"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":180,"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":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/app_paths.rs#L162-L198","documentation":"package_full_names_for_family calls the Win32 AppX API GetPackagesByPackageFamily twice: first with null buffers to learn the required count/buffer_length, then with allocated buffers. This bail fires when the FIRST (sizing) call returns an unexpected Win32 error — anything other than APPMODEL_ERROR_NO_PACKAGE, empty success, or ERROR_INSUFFICIENT_BUFFER — meaning the package enumeration could not be started at all.","triggerScenarios":"Calling query_registered_windows_packages (used to locate the installed Codex AppX package) on Windows when the first GetPackagesByPackageFamily probe returns a Win32 error code such as E_INVALIDARG, RPC/registry failures, or an unknown family name on unusual SKU/containers.","commonSituations":"Running on non-standard Windows editions (Server, LTSC) without AppX/AppXDeploymentServer services running; running in sandboxed/CI environments where the AppX registry hive is unavailable; a corrupted AppModel state repository.","solutions":["Check the logged numeric Win32 code (first.0) against Win32 error tables to identify the root cause","Ensure the AppX-related Windows services (AppX Deployment Service) are running and the AppModel registry state is intact","Fall back to the non-AppX app directory discovery paths the crate provides (e.g. ProgramFiles-based windows_app_package_roots)","Verify the code runs on a Windows build that still supports the target package family"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// before calling, only run AppX discovery when the environment supports it\nlet appx_available = cfg!(windows) && std::path::Path::new(\"C:\\\\Windows\\\\SystemApps\").exists();","typeGuard":null,"tryCatchPattern":"match package_full_names_for_family(family) {\n    Ok(names) => names,\n    Err(e) => { log::warn!(\"AppX enumeration unavailable: {e:#}\"); Vec::new() } // fall back to ProgramFiles roots\n}","preventionTips":["Always combine AppX discovery with filesystem-based fallback roots","Log the raw Win32 status code to diagnose environment-specific failures","Test on Server/LTSC/CI Windows images where AppX may be absent"],"tags":["windows","winapi","appx","native-interop"],"backgroundTag":"api-error-response","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}