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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to