A requested entity was not found
Indicates that a specific entity requested by the client (e.g., a file or a database record) was not found. The operation can be retried if the entity might be created later.
- 1The client requested an entity with an ID that does not exist.
- 2The entity was deleted between the time the client learned of it and when it made the request.
- 3The client is connected to the wrong environment (e.g., staging instead of production) where the data does not exist.
A client requests a user profile with an ID that is not in the database.
// Client requests a user with a non-existent ID
try {
await client.getUser({ userId: "user-does-not-exist-123" });
} catch (e) {
// e.code will be grpc.status.NOT_FOUND
}expected output
StatusCode.NOT_FOUND: A requested entity was not found
Fix 1
Check the Request ID
WHEN When this error is unexpected.
// Ensure the ID being sent by the client is correct
const userId = getUserIdFromUI(); // "user-does-not-exist-123"
// Verify this ID is valid before sending the request
if (isValidUUID(userId)) {
await client.getUser({ userId });
}Why this works
Validate that the identifier being used in the request is correct and well-formed.
Fix 2
Handle Gracefully in the UI
WHEN When it is a valid outcome that an entity might not exist.
try {
const user = await client.getUser({ userId });
displayUser(user);
} catch (e) {
if (e.code === grpc.status.NOT_FOUND) {
displayUserNotFoundMessage();
}
}Why this works
In many cases, NOT_FOUND is a normal part of application flow and should be handled by presenting a user-friendly message.
✕ Retry the request in a tight loop
Unless there's a specific reason to believe the resource will be created imminently, retrying a NOT_FOUND error will just waste resources.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev