gRPC 9 FAILED_PRECONDITION vs 13 INTERNAL
Both gRPC 9 (FAILED_PRECONDITION) and 13 (INTERNAL) 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, 13 means that an internal error occurred. This means that some invariant expected by the underlying system has been broken.
Описание
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.
Описание
An internal error occurred. This means that some invariant expected by the underlying system has been broken.
Когда вы это видите
A server-side bug, a corrupted internal state, or an unexpected failure in a dependency. This is the gRPC equivalent of HTTP 500.
Как исправить
Check the server error logs and traces for the root cause. This typically indicates a bug that needs to be fixed in the server code.
Ключевые различия
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.
gRPC 13: An internal error occurred. This means that some invariant expected by the underlying system has been broken.
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.
You encounter 13 when a server-side bug, a corrupted internal state, or an unexpected failure in a dependency. This is the gRPC equivalent of HTTP 500.
Когда что использовать
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 13 (INTERNAL): Check the server error logs and traces for the root cause. This typically indicates a bug that needs to be fixed in the server code.