Skip to content

LRO fails with Unexpected state: Long-running operation had neither response nor error set. #809

@parthea

Description

@parthea

See build log in PR googleapis/gapic-generator-python#2361 which fails with the following stack trace.

        if self._exception is not None:
            # pylint: disable=raising-bad-type
            # Pylint doesn't recognize that this is valid in this case.
>           raise self._exception
E           google.api_core.exceptions.GoogleAPICallError: None Unexpected state: Long-running operation had neither response nor error set.
FAILED tests/system/test_lro.py::test_lro_no_result[grpc] - google.api_core.exceptions.GoogleAPICallError: None Unexpected state: Long-running operation had neither response nor error set.
FAILED tests/system/test_lro.py::test_lro_no_result[rest] - google.api_core.exceptions.GoogleAPICallError: None Unexpected state: Long-running operation had neither response nor error set.
FAILED tests/system/test_lro.py::test_lro_async_no_result[grpc_asyncio] - google.api_core.exceptions.GoogleAPICallError: None Unexpected state: Long-running operation had neither response nor error set.

This error happens when the LRO response does not contain a result. For example, see the response below when running showcase.

2025/03/13 23:49:19 Received Unary Request for Method: /google.longrunning.Operations/GetOperation
2025/03/13 23:49:19     Request:  name:"operations/google.showcase.v1beta1.Echo/Wait/CgwI/t3NvgYQyJqJpgM="
2025/03/13 23:49:19     Returning Response: name:"operations/google.showcase.v1beta1.Echo/Wait/CgwI/t3NvgYQyJqJpgM="  done:true
2025/03/13 23:49:19 

name and done are set but there is no result. In other words, neither error nor response is set.

As per https://github.com/googleapis/googleapis/blob/a6c9ed2d33105cb3dc9a0867a0a5d761b049b932/google/longrunning/operations.proto#L141,

Some services might not provide the result.

When services don't provide a result, the response should be None instead of the exception Unexpected state: Long-running operation had neither response nor error set.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions