gRPC

gRPC 2 UNKNOWN vs 11 OUT_OF_RANGE

Both gRPC 2 (UNKNOWN) and 11 (OUT_OF_RANGE) belong to the gRPC Status Codes category. 2 indicates that an unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code. Meanwhile, 11 means that the operation was attempted past the valid range. For example, seeking or reading past the end of a file.

Descripción

An unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.

Cuándo lo verás

The server threw an unhandled exception or returned an error that gRPC couldn't classify into a more specific status code.

Cómo solucionarlo

Check the server logs for the underlying exception. Wrap server-side errors with explicit gRPC status codes instead of letting them bubble up as UNKNOWN.

Descripción

The operation was attempted past the valid range. For example, seeking or reading past the end of a file.

Cuándo lo verás

A pagination offset exceeded the available data, or an iterator moved past the end of a collection. Unlike INVALID_ARGUMENT, this depends on the current state of the data.

Cómo solucionarlo

Check the valid range before making the request. For pagination, use the total count or next-page token to avoid requesting beyond the last page.

Diferencias clave

1.

gRPC 2: An unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.

2.

gRPC 11: The operation was attempted past the valid range. For example, seeking or reading past the end of a file.

3.

You encounter 2 when the server threw an unhandled exception or returned an error that gRPC couldn't classify into a more specific status code.

4.

You encounter 11 when a pagination offset exceeded the available data, or an iterator moved past the end of a collection. Unlike INVALID_ARGUMENT, this depends on the current state of the data.

Cuándo usar cada uno

For 2 (UNKNOWN): Check the server logs for the underlying exception. Wrap server-side errors with explicit gRPC status codes instead of letting them bubble up as UNKNOWN. For 11 (OUT_OF_RANGE): Check the valid range before making the request. For pagination, use the total count or next-page token to avoid requesting beyond the last page.

Saber más