gRPC

gRPC 9 FAILED_PRECONDITION vs 11 OUT_OF_RANGE

Both gRPC 9 (FAILED_PRECONDITION) and 11 (OUT_OF_RANGE) belong to the gRPC Status Codes category. 9 indicates that the operation was rejected because the system is not in a state required for the operation's execution. For example, deleting a non-empty directory. Meanwhile, 11 means that the operation was attempted past the valid range. For example, seeking or reading past the end of a file.

الوصف

The operation was rejected because the system is not in a state required for the operation's execution. For example, deleting a non-empty directory.

متى تراه

The request is valid on its own, but the system's current state doesn't allow it — like trying to delete a non-empty directory or update a resource that has been modified concurrently.

كيفية الإصلاح

Bring the system into the required state before retrying. For example, empty the directory first, or re-read the resource to get the latest version before updating.

الوصف

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

متى تراه

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.

كيفية الإصلاح

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.

الفروق الرئيسية

1.

gRPC 9: The operation was rejected because the system is not in a state required for the operation's execution. For example, deleting a non-empty directory.

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 9 when the request is valid on its own, but the system's current state doesn't allow it — like trying to delete a non-empty directory or update a resource that has been modified concurrently.

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.

متى تستخدم أيًا منهما

For 9 (FAILED_PRECONDITION): Bring the system into the required state before retrying. For example, empty the directory first, or re-read the resource to get the latest version before updating. 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.

اعرف المزيد