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.