# rpc 错误：code = NotFound desc = 资源未找到：订单 998877

- **ID:** `go/grpc-not-found-service-method`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

请求的资源在服务器上不存在。NotFound 是合法的应用层响应，但常与 Unimplemented 混淆——后者表示方法本身缺失。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Handle NotFound as a normal application outcome and map it to your domain error:

resp, err := client.GetOrder(ctx, &pb.GetReq{Id: id})
if status.Code(err) == codes.NotFound {
    return nil, ErrOrderNotFound
}
   ```
2. **** (80% 成功率)
   ```
   When eventual creation is expected, poll with a bounded retry and backoff:

backoff := time.Second
for i := 0; i < 10; i++ {
    _, err := client.Get(ctx, req)
    if status.Code(err) != codes.NotFound { return err }
    time.Sleep(backoff); backoff *= 2
}
   ```

## 无效尝试

- **** — Without an explicit wait/backoff and an expectation of eventual creation, retrying a NotFound just repeats the same lookup. (80% 失败率)
- **** — Many NotFound responses are expected (deleted resources, bad user input); paging on-call for them causes alert fatigue. (60% 失败率)
