You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "AlexStocks (via GitHub)" <gi...@apache.org> on 2026/07/28 02:48:54 UTC
[I] [Bug] Improper error comparison/wrapping breaks errors.Is/As (== io.EOF, %v instead of %w) (P1/P2) [dubbo-go]
AlexStocks opened a new issue, #3560:
URL: https://github.com/apache/dubbo-go/issues/3560
## Summary
Several places compare errors with `==` against sentinel errors, or wrap errors with `%v` instead of `%w`. Once an error is wrapped (or comes from a wrapped source), `==` silently fails and the error chain is broken, so error-chain-based handling (`errors.Is`/`errors.As`) no longer works.
## Affected locations
| File:Line | Code | Problem |
|-----------|------|---------|
| `protocol/jsonrpc/server.go:329` | `if err == io.EOF \|\| err == io.ErrUnexpectedEOF { ... }` | Sentinel comparison fails if `err` is wrapped. Use `errors.Is(err, io.EOF)`. |
| `protocol/jsonrpc/server.go:127` | `err == io.EOF` (bufio.Peek) | Same — prefer `errors.Is`. |
| `protocol/triple/reflection/serverreflection.go:169` | `err == io.EOF` (grpc stream) | Same — prefer `errors.Is`. |
| `otel/trace/exporter.go:77` | `err = fmt.Errorf("failed to create %s exporter: %v", config.Exporter, err)` | Uses `%v`, breaking the error chain; downstream `errors.Is`/`As` can't unwrap it. Should be `%w`. |
Note: the core transport paths already use `errors.Is` correctly (e.g. `dual_transport.go`, `error.go` compare `context.DeadlineExceeded`/`context.Canceled` with `errors.Is`), so this is an inconsistency rather than a pervasive bug.
## Impact
- A wrapped `io.EOF`/cancelled error bypasses the sentinel branches → incorrect handling or silent mismatch.
- `%v` wrapping in the OTel exporter hides the root cause from `errors.Is`/`As` consumers.
## Suggested fix
- Replace `err == io.EOF` / `== io.ErrUnexpectedEOF` with `errors.Is(err, ...)`.
- Replace `%v` with `%w` when wrapping errors that should remain inspectable.
## Verification
`GOTOOLCHAIN=local go vet ./...` on develop tip (HEAD 53d81d17) reports **zero** warnings (see #3552). `go vet` does not flag `==` vs `errors.Is` or `%v` vs `%w` — needs the `errorlint` linter (proposed in the enhanced golangci config) to catch these.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [Bug] Improper error comparison/wrapping breaks errors.Is/As (== io.EOF, %v instead of %w) (P1/P2) [dubbo-go]
Posted by "nightcityblade (via GitHub)" <gi...@apache.org>.
nightcityblade commented on issue #3560:
URL: https://github.com/apache/dubbo-go/issues/3560#issuecomment-5132890332
Hi, I'd like to work on this. I'll update the sentinel error checks and wrapping behavior, add focused regression tests, and submit a PR shortly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [Bug] Improper error comparison/wrapping breaks errors.Is/As (== io.EOF, %v instead of %w) (P1/P2) [dubbo-go]
Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks closed issue #3560: [Bug] Improper error comparison/wrapping breaks errors.Is/As (== io.EOF, %v instead of %w) (P1/P2)
URL: https://github.com/apache/dubbo-go/issues/3560
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org