{"record":{"id":"f80233bba30b305d","repo":"BigPizzaV3/CodexPlusPlus","slug":"getpackagepathbyfullname-failed-with","errorCode":null,"errorMessage":"GetPackagePathByFullName failed with {}","messagePattern":"GetPackagePathByFullName failed with (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/app_paths.rs","lineNumber":226,"sourceCode":"    use std::os::windows::ffi::OsStringExt;\n    use windows::Win32::Foundation::{ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS};\n    use windows::Win32::Storage::Packaging::Appx::GetPackagePathByFullName;\n    use windows::core::{PCWSTR, PWSTR};\n\n    let full_name = full_name\n        .encode_utf16()\n        .chain(std::iter::once(0))\n        .collect::<Vec<_>>();\n    let mut path_length = 0u32;\n    let first = unsafe {\n        GetPackagePathByFullName(\n            PCWSTR(full_name.as_ptr()),\n            &mut path_length,\n            PWSTR(std::ptr::null_mut()),\n        )\n    };\n    if first != ERROR_INSUFFICIENT_BUFFER {\n        bail!(\"GetPackagePathByFullName failed with {}\", first.0);\n    }\n    let mut path = vec![0u16; path_length as usize];\n    let status = unsafe {\n        GetPackagePathByFullName(\n            PCWSTR(full_name.as_ptr()),\n            &mut path_length,\n            PWSTR(path.as_mut_ptr()),\n        )\n    };\n    if status != ERROR_SUCCESS {\n        bail!(\"GetPackagePathByFullName failed with {}\", status.0);\n    }\n    let end = path\n        .iter()\n        .position(|value| *value == 0)\n        .unwrap_or(path.len());\n    Ok(PathBuf::from(OsString::from_wide(&path[..end])))\n}","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/app_paths.rs#L208-L244","documentation":"package_path_by_full_name also uses the two-call pattern with GetPackagePathByFullName: a null-pointer call to get the needed path_length, then a buffered call. This bail fires when the FIRST (sizing) call returns anything other than ERROR_INSUFFICIENT_BUFFER. Notably ERROR_SUCCESS with zero-length or APPMODEL_ERROR_NO_PACKAGE here are treated as failures rather than 'not found', so the error surfaces whenever the package full name cannot be resolved to a path at all.","triggerScenarios":"Resolving the install path of a package full name returned by GetPackagesByPackageFamily when that package was removed/re-registered between the two API calls, or when the full name is invalid/unregistered (APPMODEL_ERROR_NO_PACKAGE), or an access/arg error occurs.","commonSituations":"A Store update replaced the package (full names change after Codex updates, per the code comment) during enumeration; a staging-removal race; querying on a machine where the package family is not provisioned.","solutions":["Treat it as a per-package failure and skip that package (the caller's with_context already labels it with the full name), then re-enumerate to pick up the new package identity","Retry after the Store update/install completes since full names change on update","Verify the package is still registered via GetPackagesByPackageFamily before resolving its path","Check the logged Win32 code (e.g. 15700-series APPMODEL errors mean package not found)"],"exampleFix":"// before\nlet install_location = package_path_by_full_name(&full_name)\n    .with_context(|| format!(\"failed to resolve registered package {full_name}\"))?;\n// after\nlet Ok(install_location) = package_path_by_full_name(&full_name) else {\n    eprintln!(\"skipping stale package {full_name}\");\n    continue;\n};","handlingStrategy":"fallback","validationCode":"// check the package is still registered before resolving its path\nlet still_registered = package_full_names_for_family(family)?.iter().any(|n| n == &full_name);\nif !still_registered { skip(); }","typeGuard":null,"tryCatchPattern":"let path = match package_path_by_full_name(&full_name) {\n    Ok(p) => p,\n    Err(e) => { log::debug!(\"skipping {full_name}: {e:#}\"); continue; }\n};","preventionTips":["Treat each package's path resolution as independently skippable (the API can return APPMODEL_ERROR_NO_PACKAGE if the package vanished)","Re-enumerate after Codex Store updates since full names change","Log the numeric Win32 code — 15700-series codes mean package-not-found rather than an environment fault"],"tags":["windows","winapi","appx","package-resolution"],"backgroundTag":"resource-not-found","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"}