File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ func NewDifyHandler() *DifyHandler {
3333 return & DifyHandler {}
3434}
3535
36- // RetrievalHealth handles GET /v1/dify/retrieval/health.
36+ // RetrievalHealth handles GET /api/ v1/dify/retrieval/health.
3737//
3838// Returns a constant success envelope. Dify probes this endpoint to check
3939// whether the RAGFlow external-knowledge connector is reachable, so it must
@@ -43,7 +43,7 @@ func NewDifyHandler() *DifyHandler {
4343// @Tags dify
4444// @Produce json
4545// @Success 200 {object} map[string]interface{}
46- // @Router /v1/dify/retrieval/health [get]
46+ // @Router /api/ v1/dify/retrieval/health [get]
4747func (h * DifyHandler ) RetrievalHealth (c * gin.Context ) {
4848 c .JSON (http .StatusOK , gin.H {
4949 "code" : common .CodeSuccess ,
Original file line number Diff line number Diff line change @@ -56,8 +56,11 @@ func TestDifyRetrievalHealthReturnsTrueEnvelope(t *testing.T) {
5656 }
5757}
5858
59- func TestDifyRetrievalHealthDoesNotRequireAuth (t * testing.T ) {
60- // Public probe: must succeed even with no user attached to the context.
59+ func TestDifyRetrievalHealthHandlerDoesNotReadUser (t * testing.T ) {
60+ // Handler-scope contract: the handler itself must not call GetUser or
61+ // otherwise depend on an authenticated context, so that mounting it on
62+ // the public apiNoAuth group succeeds without middleware. Router-level
63+ // no-auth placement is verified by the router setup, not here.
6164 gin .SetMode (gin .TestMode )
6265
6366 r := gin .New ()
@@ -72,8 +75,10 @@ func TestDifyRetrievalHealthDoesNotRequireAuth(t *testing.T) {
7275 }
7376
7477 var body map [string ]interface {}
75- _ = json .Unmarshal (resp .Body .Bytes (), & body )
78+ if err := json .Unmarshal (resp .Body .Bytes (), & body ); err != nil {
79+ t .Fatalf ("unmarshal: %v body=%s" , err , resp .Body .String ())
80+ }
7681 if code , _ := body ["code" ].(float64 ); int (code ) != int (common .CodeSuccess ) {
77- t .Errorf ("unauthenticated probe should succeed, got code=%v" , body ["code" ])
82+ t .Errorf ("handler returned non-success without user context: code=%v" , body ["code" ])
7883 }
7984}
You can’t perform that action at this time.
0 commit comments