{"record":{"id":"704fa8ce66714832","repo":"openai/codex","slug":"helperdpapiprotectfailed","errorCode":"HelperDpapiProtectFailed","errorMessage":"dpapi protect failed for offline user: {err}","messagePattern":"dpapi protect failed for offline user: (.+?)","errorType":"error_code","errorClass":"SetupFailure","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs","lineNumber":423,"sourceCode":"fn write_secrets(\n    codex_home: &Path,\n    offline_user: &str,\n    offline_pwd: &str,\n    online_user: &str,\n    online_pwd: &str,\n) -> Result<()> {\n    let secrets_dir = sandbox_secrets_dir(codex_home);\n    std::fs::create_dir_all(&secrets_dir).map_err(|err| {\n        anyhow::Error::new(SetupFailure::new(\n            SetupErrorCode::HelperUsersFileWriteFailed,\n            format!(\n                \"failed to create secrets dir {}: {err}\",\n                secrets_dir.display()\n            ),\n        ))\n    })?;\n    let offline_blob = dpapi_protect(offline_pwd.as_bytes()).map_err(|err| {\n        anyhow::Error::new(SetupFailure::new(\n            SetupErrorCode::HelperDpapiProtectFailed,\n            format!(\"dpapi protect failed for offline user: {err}\"),\n        ))\n    })?;\n    let online_blob = dpapi_protect(online_pwd.as_bytes()).map_err(|err| {\n        anyhow::Error::new(SetupFailure::new(\n            SetupErrorCode::HelperDpapiProtectFailed,\n            format!(\"dpapi protect failed for online user: {err}\"),\n        ))\n    })?;\n    let users = SandboxUsersFile {\n        version: SETUP_VERSION,\n        offline: SandboxUserRecord {\n            username: offline_user.to_string(),\n            password: BASE64.encode(offline_blob),\n        },\n        online: SandboxUserRecord {\n            username: online_user.to_string(),","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs#L405-L441","documentation":"The DPAPI CryptProtectData helper failed while encrypting the offline sandbox user's password before writing it to the secrets directory. Without a protected blob the credentials cannot be persisted safely, so secret writing is aborted with the underlying error chained.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:423 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the chained error for the CryptProtectData GetLastError code","Verify DPAPI machine-scope protection is available (the code uses CRYPTPROTECT_LOCAL_MACHINE) and not blocked by policy or a broken credential store","Ensure the process identity can access the DPAPI machine keys; running elevated usually resolves protection-key access failures"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}