canopy-network/canopy · error · Exception

Unexpected state read response

Error message

Unexpected state read response

What it means

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.

Source

Thrown at plugin/kotlin/src/main/kotlin/com/canopy/plugin/PluginClient.kt:131

    }

    /**
     * Read state from FSM
     */
    fun stateRead(contract: Contract, request: PluginStateReadRequest): PluginStateReadResponse {
        val msg = PluginToFSM.newBuilder()
            .setId(contract.fsmId)
            .setStateRead(request)
            .build()

        val response = sendSync(contract, msg)

        return when {
            response.hasStateRead() -> response.stateRead
            response.hasError() -> PluginStateReadResponse.newBuilder()
                .setError(response.error)
                .build()
            else -> throw Exception("Unexpected state read response")
        }
    }

    /**
     * Write state to FSM
     */
    fun stateWrite(contract: Contract, request: PluginStateWriteRequest): PluginStateWriteResponse {
        val msg = PluginToFSM.newBuilder()
            .setId(contract.fsmId)
            .setStateWrite(request)
            .build()

        val response = sendSync(contract, msg)

        return when {
            response.hasStateWrite() -> response.stateWrite
            response.hasError() -> PluginStateWriteResponse.newBuilder()
                .setError(response.error)

View on GitHub (pinned to ee8197d91d)

Solutions

  1. Check that request ids are not being reused or interleaved incorrectly across contracts.
  2. Confirm both sides use the same PluginToFSM/FSMToPlugin proto schema.
  3. Restart the plugin/FSM pair to resynchronize the message stream.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at plugin/kotlin/src/main/kotlin/com/canopy/plugin/PluginClient.kt:131 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of canopy-network/canopy@ee8197d91d (2026-09-06). Data as JSON: /api/errors/a68dcde28f042f45. Report an issue: GitHub.