{"record":{"id":"d4e7f07b43bd8dac","repo":"BigPizzaV3/CodexPlusPlus","slug":"invalid-oai-sky-package-json-path","errorCode":null,"errorMessage":"invalid @oai/sky package.json path","messagePattern":"invalid @oai/sky package\\.json path","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/computer_use_guard.rs","lineNumber":186,"sourceCode":"            changed: false,\n            package_json: Some(package_json.to_path_buf()),\n            backup_path: None,\n        });\n    }\n\n    let existing = std::fs::read_to_string(package_json)\n        .with_context(|| format!(\"failed to read {}\", package_json.display()))?;\n    let Some(updated) = add_sky_internal_computer_use_export(&existing)? else {\n        return Ok(RuntimeCompatResult {\n            changed: false,\n            package_json: Some(package_json.to_path_buf()),\n            backup_path: None,\n        });\n    };\n\n    let backup_path = package_json\n        .parent()\n        .ok_or_else(|| anyhow::anyhow!(\"invalid @oai/sky package.json path\"))?\n        .join(SKY_PACKAGE_EXPORTS_BACKUP);\n    if !backup_path.exists() {\n        std::fs::copy(package_json, &backup_path).with_context(|| {\n            format!(\n                \"failed to back up {} to {}\",\n                package_json.display(),\n                backup_path.display()\n            )\n        })?;\n    }\n    atomic_write_runtime_file(package_json, updated.as_bytes())?;\n    Ok(RuntimeCompatResult {\n        changed: true,\n        package_json: Some(package_json.to_path_buf()),\n        backup_path: Some(backup_path),\n    })\n}\n","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/1f431ae49b57b3055e0e6845ba6156c6b4232b4d/crates/codex-plus-core/src/computer_use_guard.rs#L168-L204","documentation":"In the @oai/sky computer-use compatibility patcher (crates/codex-plus-core/src/computer_use_guard.rs:186), after deciding the package.json must be rewritten, the code joins the backup filename onto package_json.parent() — Path::parent() returns None only for empty paths or the filesystem root '/'. This is a defensive invariant: a real package.json path inside a runtime directory always has a parent, so hitting it means the path itself was degenerate.","triggerScenarios":"The guard runs with a resolved @oai/sky package.json path that is '' or '/' — e.g. a home/runtime-dir resolution bug that produced an empty string and it was then Path::new'd, or root was used as a sentinel.","commonSituations":"Essentially unreachable in normal operation; appears only with corrupted install paths, a misconfigured home directory pointing at root, or a code change that passes an unresolved path variable.","solutions":["Log the package_json value at the call site — it will be empty or '/' and points at the upstream path-resolution bug","Check how the @oai/sky package location is resolved (home dir join) and ensure it yields a nested, non-root path","Report as a bug if a stock install reproduces it — the input path should never be degenerate"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before running the guard, sanity-check the resolved runtime paths\nfn runtime_paths_sane(p: &std::path::Path) -> bool {\n    p.is_absolute() && p.parent().is_some() && p.file_name().is_some()\n}\nensure!(runtime_paths_sane(&sky_package_json), \"degenerate @oai/sky path: {}\", sky_package_json.display());","typeGuard":"fn path_has_parent(p: &std::path::Path) -> bool { p.parent().is_some() }","tryCatchPattern":null,"preventionTips":["Assert resolved install/home paths are non-root before joining filenames","Fail fast at home-dir detection with a clear message instead of propagating empty strings","Log resolved paths once at startup to catch degenerate values early"],"tags":["path-validation","defensive-invariant","computer-use-guard","filesystem"],"backgroundTag":"path-without-parent-directory","analyzedSha":"1f431ae49b57b3055e0e6845ba6156c6b4232b4d","analyzedAt":"2026-08-16T20:54:18.598Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}