You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "lizining1231 (via GitHub)" <gi...@apache.org> on 2026/08/12 14:42:43 UTC

[PR] docs(triple): complete Triple Header/Error comments and unit test coverage [dubbo-go]

lizining1231 opened a new pull request, #3648:
URL: https://github.com/apache/dubbo-go/pull/3648

   ### Description
   Fixes #3644 (task 8)
   
   This PR adds doc comments for `ExtractFromOutgoingContext`, `SetHeader`,`SetTrailer`, `SendHeader`, and `Error.Error`, clarifying their behavior, error return conditions, and how the framework uses them internally. Italso adds 13 boundary tests covering previously untested branches.
   
   ### Changes
   
   - **header.go**
     - `ExtractFromOutgoingContext`: new doc comment. Returns nil if no outgoing headers have been set. The framework calls it internally — on the client side to populate request headers before sending, and on the server side to merge handler-set headers into response trailers.
     - `SetHeader` / `SetTrailer` / `SendHeader`: augmented to state that they return a `CodeInternal` error when called outside a Triple handler context.
   - **error.go**
     - `Error.Error`: new doc comment. Returns the status code's name and, if non-empty, the underlying error's message separated by a colon.
   
   **header_test.go (8 tests):**
   
   | Test | What it verifies |
   | --- | --- |
   | `TestDecodeBinaryHeader` | Handles empty, unpadded (`len%4 != 0` → RawStdEncoding), padded (`len%4 == 0` with `=`), and naturally-aligned (`len%4 == 0` without `=`) base64 inputs |
   | `TestExtractFromOutgoingContext` | Returns nil when no outgoing headers are set; returns the headers when set via `NewOutgoingContext` |
   | `TestNewOutgoingContextReplacesExisting` | A second call to `NewOutgoingContext` replaces existing headers instead of merging |
   | `TestAppendToOutgoingContextPanicsOnOddKV` | Panics when given an odd number of key-value arguments |
   | `TestSetHeader` | Within a handler context, headers are merged into `ResponseHeader` |
   | `TestSetTrailer` | Within a handler context, headers are merged into `ResponseTrailer` |
   | `TestSetHeaderOutsideHandler` | Outside a handler context, returns `CodeInternal` |
   | `TestSetTrailerOutsideHandler` | Outside a handler context, returns `CodeInternal` |
   
   **error_test.go (5 tests):**
   
   | Test | What it verifies |
   | --- | --- |
   | `TestNewWireError` | `IsWireError` returns true for wire errors created by `NewWireError` (including when wrapped), false for regular `*Error` and non-triple errors |
   | `TestNewErrorDetailWithAny` | Uses an `*anypb.Any` directly without wrapping it into another `Any` |
   | `TestErrorDetailBytesReturnsCopy` | `Bytes()` returns a copy; mutating the returned slice does not affect internal state |
   | `TestWrapIfContextError` | `context.Canceled` → `CodeCanceled`, `context.DeadlineExceeded` → `CodeDeadlineExceeded` (both preserve the `errors.Is` chain); already-coded errors returned unchanged (same pointer); plain errors returned as-is; nil returns nil |
   | `TestWrapIfUncoded` | nil returns nil; already-coded errors preserved (same pointer); `context.Canceled` wrapped with `CodeCanceled` via `wrapIfContextError`; plain errors wrapped with `CodeUnknown` |
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] Code has passed local testing
   - [x] I have added tests that prove my fix is effective or that my feature works
   


-- 
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: [PR] docs(triple): complete Triple Header/Error comments and unit test coverage [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3648:
URL: https://github.com/apache/dubbo-go/pull/3648#issuecomment-5268364922

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3648) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3648&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3648&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3648&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3648&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3648&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3648)
   
   


-- 
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: [PR] docs(triple): complete Triple Header/Error comments and unit test coverage [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3648:
URL: https://github.com/apache/dubbo-go/pull/3648#issuecomment-5268359413

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3648) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3648&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3648&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3648&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3648&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3648&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3648)
   
   


-- 
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: [PR] docs(triple): complete Triple Header/Error comments and unit test coverage [dubbo-go]

Posted by "lizining1231 (via GitHub)" <gi...@apache.org>.
lizining1231 closed pull request #3648: docs(triple): complete Triple Header/Error comments and unit test coverage
URL: https://github.com/apache/dubbo-go/pull/3648


-- 
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: [PR] docs(triple): complete Triple Header/Error comments and unit test coverage [dubbo-go]

Posted by "lizining1231 (via GitHub)" <gi...@apache.org>.
lizining1231 closed pull request #3648: docs(triple): complete Triple Header/Error comments and unit test coverage
URL: https://github.com/apache/dubbo-go/pull/3648


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