{"record":{"id":"e80bc69c0b862604","repo":"openai/codex","slug":"flagalreadyready","errorCode":"FlagAlreadyReady","errorMessage":"Flag is already ready. Impossible to subscribe","messagePattern":"Flag is already ready\\. Impossible to subscribe","errorType":"exception","errorClass":"ReadinessError","httpStatus":null,"severity":"error","filePath":"codex-rs/utils/readiness/src/lib.rs","lineNumber":196,"sourceCode":"            return;\n        }\n        // Await changes until true is observed.\n        while rx.changed().await.is_ok() {\n            if *rx.borrow() {\n                break;\n            }\n        }\n    }\n}\n\nmod errors {\n    use thiserror::Error;\n\n    #[derive(Debug, Error)]\n    pub enum ReadinessError {\n        #[error(\"Failed to acquire readiness token lock\")]\n        TokenLockFailed,\n        #[error(\"Flag is already ready. Impossible to subscribe\")]\n        FlagAlreadyReady,\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use std::sync::Arc;\n    use std::sync::atomic::Ordering;\n\n    use super::Readiness;\n    use super::ReadinessFlag;\n    use super::Token;\n    use super::errors::ReadinessError;\n    use assert_matches::assert_matches;\n\n    #[tokio::test]\n    async fn subscribe_and_mark_ready_roundtrip() -> Result<(), ReadinessError> {\n        let flag = ReadinessFlag::new();","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/utils/readiness/src/lib.rs#L178-L214","documentation":"ReadinessError::FlagAlreadyReady, a thiserror-defined sentinel variant. It fires when a caller attempts to subscribe to readiness change notifications for a flag whose value is already true; there is no future transition to await, so a subscription is impossible.","triggerScenarios":"Thrown at codex-rs/utils/readiness/src/lib.rs:196 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the flag's current value before subscribing and treat an already-ready flag as immediately complete instead of subscribing","Use the watch channel fast-path check (borrow() == true) to short-circuit before calling subscribe","Restructure code so subscriptions are created only once, before the flag can be set"],"exampleFix":null,"handlingStrategy":"type-guard","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"}