{"record":{"id":"a68dcde28f042f45","repo":"canopy-network/canopy","slug":"unexpected-state-read-response","errorCode":null,"errorMessage":"Unexpected state read response","messagePattern":"Unexpected state read response","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"plugin/kotlin/src/main/kotlin/com/canopy/plugin/PluginClient.kt","lineNumber":131,"sourceCode":"    }\n\n    /**\n     * Read state from FSM\n     */\n    fun stateRead(contract: Contract, request: PluginStateReadRequest): PluginStateReadResponse {\n        val msg = PluginToFSM.newBuilder()\n            .setId(contract.fsmId)\n            .setStateRead(request)\n            .build()\n\n        val response = sendSync(contract, msg)\n\n        return when {\n            response.hasStateRead() -> response.stateRead\n            response.hasError() -> PluginStateReadResponse.newBuilder()\n                .setError(response.error)\n                .build()\n            else -> throw Exception(\"Unexpected state read response\")\n        }\n    }\n\n    /**\n     * Write state to FSM\n     */\n    fun stateWrite(contract: Contract, request: PluginStateWriteRequest): PluginStateWriteResponse {\n        val msg = PluginToFSM.newBuilder()\n            .setId(contract.fsmId)\n            .setStateWrite(request)\n            .build()\n\n        val response = sendSync(contract, msg)\n\n        return when {\n            response.hasStateWrite() -> response.stateWrite\n            response.hasError() -> PluginStateWriteResponse.newBuilder()\n                .setError(response.error)","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/plugin/kotlin/src/main/kotlin/com/canopy/plugin/PluginClient.kt#L113-L149","documentation":"Thrown in PluginClient.stateRead when the FSM's response to a state-read request is neither a stateRead result nor an error — an out-of-protocol reply. The request/response ids or message types are desynchronized, so the caller cannot get a state read result at all.","triggerScenarios":"Thrown at plugin/kotlin/src/main/kotlin/com/canopy/plugin/PluginClient.kt:131 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that request ids are not being reused or interleaved incorrectly across contracts.","Confirm both sides use the same PluginToFSM/FSMToPlugin proto schema.","Restart the plugin/FSM pair to resynchronize the message stream."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ee8197d91dd410f6592cb650a94c925ee6dc8bad","analyzedAt":"2026-09-06T09:30:15.973Z","contentChangedAt":"2026-09-06T09:30:15.973Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}