dubbo-go-bot opened a new pull request, #782:
URL: https://github.com/apache/dubbo-go-pixiu/pull/782

   ## 🔄 Upstream Sync from Community Fork
   
   This PR automatically syncs changes from the community fork to the upstream 
repository.
   
   ### Original Contribution
   
   - **Author**: @nanjiek
   - **Original PR**: https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14
   - **Merged at**: 2025-10-21 09:43:10 UTC
   
   ### Original PR Description
   
   ---
   
   ### **User description**
   What this PR does:
   
   Replaces all instances of erroresponse with errResponse, ensuring a unified 
error handling mechanism.
   Implements the ErrorBuilder pattern for each error type, providing a 
standardized error response structure.
   Adds support for attaching original error information, improving debugging 
and logging.
   Which issue(s) this PR fixes:
   
   Resolves issue 
[https://github.com/apache/dubbo-go-pixiu/issues/755](https://github.com/apache/dubbo-go-pixiu/issues/755),
 unifying error codes in the Pixiu project and improving consistency.
   Special notes for your reviewer:
   
   Please verify the new error response mechanism, especially the handling of 
attached error information.
   
   Review the changes related to the unified error codes and make sure they are 
consistent across the project.
   
   PR Type
   Enhancement, Tests
   
   Description
   Unified error response mechanism with ErrorBuilder pattern across all filters
   
   Added MCP (Model Context Protocol) authentication filter with JWT validation
   
   Replaced inconsistent error handling with standardized ErrorResponse 
structure
   
   Comprehensive test coverage for error handling and JWT validation
   
   ```
   
   
   ___
   
   ### **PR Type**
   Enhancement, Tests
   
   
   ___
   
   ### **Description**
   - Unified error response mechanism with ErrorBuilder pattern across all 
filters
   
   - Replaced inconsistent error handling with standardized ErrorResponse 
structure
   
   - Removed hardcoded error response constants from filter.go
   
   - Added comprehensive test coverage for error handling and JSON serialization
   
   - Improved timeout detection using context.DeadlineExceeded and os.IsTimeout
   
   
   ___
   
   ### Diagram Walkthrough
   
   
   ```mermaid
   flowchart LR
     A["Old Error Handling<br/>Inconsistent responses"] -->|"Replace with"| 
B["ErrorBuilder Pattern<br/>Standardized responses"]
     B --> C["ErrorResponse struct<br/>Status + Message + Error"]
     C --> D["Predefined builders<br/>BadRequest, NotFound, etc"]
     D --> E["All filters updated<br/>Consistent error replies"]
     E --> F["Comprehensive tests<br/>JSON marshaling verified"]
   ```
   
   
   
   <details> <summary><h3> File Walkthrough</h3></summary>
   
   <table><thead><tr><th></th><th align="left">Relevant 
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>19
 files</summary><table>
   <tr>
     <td><strong>filter.go</strong><dd><code>Removed hardcoded error response 
body constants</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-c1cacef076033b4de6ea4ec57448d912bb9ae9677835ed822eb300b5bc0f2ea0";>+0/-8</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>erroresponse.go</strong><dd><code>New ErrorBuilder pattern 
with predefined error types</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-427911168ffa852ef2d4b39a7983030694be206a72d353570869780e3d4afa8f";>+128/-0</a>&nbsp;
 </td>
   
   </tr>
   
   <tr>
     <td><strong>context.go</strong><dd><code>Removed old ErrResponse struct 
definition</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-d33e860dc7e2c07b95ec0c928c2a95a3df1b82c22350f559efad76ed5acc6e6e";>+0/-4</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>manager.go</strong><dd><code>Updated error handling to use 
ErrorBuilder pattern</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
</dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-084e3bd18511b9fe5fccf149b2932043c90ea2b60b8b044231b48f4b235de01e";>+4/-3</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>routerfilter.go</strong><dd><code>Replaced manual JSON 
marshaling with ErrorBuilder</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-c56d5fcffcf6fc816afb422cbea38cdae24db805322418640a98b13c344f7a71";>+4/-4</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>jwt.go</strong><dd><code>Updated JWT error response to use 
ErrorBuilder</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-94f0a5f3934665494c8cc2084f743961056a15d9b3e574962380b8d187045d6a";>+3/-2</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>authority.go</strong><dd><code>Replaced hardcoded 403 response 
with Forbidden builder</code>&nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-24dc3b9f1ddc8f7e0e589453bbd92b2ad8cbf6ba5dad3995064a5fec6e592f83";>+2/-5</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>csrf.go</strong><dd><code>Updated CSRF validation errors to 
use ErrorBuilder</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
</dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-dd67f7422864aa50fb32280176cc47f78a036eeefc67e9e9adcf60eda2038f66";>+5/-6</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>event.go</strong><dd><code>Replaced manual error response with 
InternalError builder</code></dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-f11635b1b152b09b8cb86259dc902c41a9c4300cc6747c80de4645a4f257a981";>+2/-2</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>api_config.go</strong><dd><code>Updated API config validation 
errors to use ErrorBuilder</code>&nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-e91cca4adadd5ec3751c31e8e1b1b921b2b2537f717f00d5be97dc9775c01cca";>+4/-6</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>dubbo.go</strong><dd><code>Replaced all error responses with 
ErrorBuilder pattern</code>&nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-eac58455c0a43fcdd60c5315666741747a95d43d79d839438c853072a411bf65";>+25/-21</a>&nbsp;
 </td>
   
   </tr>
   
   <tr>
     <td><strong>grpc.go</strong><dd><code>Updated gRPC error handling with 
improved timeout detection</code></dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-ddb337191d25183c0a03323062876cf94c374c17167f3f1dcea1ebf08bf77837";>+39/-13</a>&nbsp;
 </td>
   
   </tr>
   
   <tr>
     <td><strong>routerfilter.go</strong><dd><code>Replaced manual JSON 
marshaling with ErrorBuilder</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-a8b86c386eb00f625a2807472fd846ea8f0c9fecd013ea79df567c707df12266";>+8/-7</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>call.go</strong><dd><code>Updated remote call errors to use 
ErrorBuilder pattern</code>&nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-7d79f427e1616490d12457f80993be86fb8577aa4781602c8a64328a5061e250";>+11/-7</a>&nbsp;
 &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>filter.go</strong><dd><code>Removed sendJSONError helper, 
using ErrorBuilder instead</code>&nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-37d19eb2e8a72025536b0a071b33558ce790bee9fbe05d43c62c7b7c5194b10a";>+8/-11</a>&nbsp;
 &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>filter.go</strong><dd><code>Updated MCP server error responses 
to use ErrorBuilder</code>&nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-43bef22a883f33fd267afc7e46cb83e95625298996531f7e692cbaa0e6d51167";>+2/-1</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>response.go</strong><dd><code>Updated MCP error handler to use 
ErrorBuilder pattern</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-60d038544338edc80f3c82864fddc3f00153ba14e6fcaad377da839351781529";>+3/-1</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>circuit_breaker.go</strong><dd><code>Replaced hardcoded 503 
response with ServiceUnavailable builder</code></dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-0a8f3440b2de2439217b0ca5763b0cde0feaefc3c870c5c1a5e6bd487556c04f";>+2/-2</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
   <tr>
     <td><strong>rate_limit.go</strong><dd><code>Updated rate limit error to 
use RateLimited builder</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
</dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-02c0cf9813c0fc6b6b418900365ab3d71474b738dceb4e9e600ce22662b0a79d";>+2/-7</a>&nbsp;
 &nbsp; &nbsp; </td>
   
   </tr>
   
</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>1
 files</summary><table>
   <tr>
     <td><strong>context_test.go</strong><dd><code>Added comprehensive error 
handling and JSON tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-9d26a5c3f63492d18f571c8a7f7b50f90d1beef699f7ae24dfefe3bff60254e0";>+431/-0</a>&nbsp;
 </td>
   
   </tr>
   
</table></details></td></tr><tr><td><strong>Bug_fix</strong></td><td><details><summary>1
 files</summary><table>
   <tr>
     <td><strong>metric.go</strong><dd><code>Updated Prometheus filter errors 
and fixed filter status</code>&nbsp; </dd></td>
     <td><a 
href="https://github.com/dubbo-go-pixiu/dubbo-go-pixiu/pull/14/files#diff-4ddc37c3dfcb2672088ad1c7d5cd28bdc6c392766d52cffb34fc81d05161b8af";>+12/-11</a>&nbsp;
 </td>
   
   </tr>
   </table></details></td></tr></tr></tbody></table>
   
   </details>
   
   ___
   
   
   
   ---
   
   All commits preserve original authorship.
   
   **Note**: Auto-created when PR #14 was merged into 
`dubbo-go-pixiu/dubbo-go-pixiu:develop`.
   
   cc @nanjiek
   


-- 
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