Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
refactor(system): drop idempotent flag from create-user response body
MidoriKuragec591f16d539a
diff --git a/docs/docs.go b/docs/docs.goindex aac91a127..73a4592a2 100644--- a/docs/docs.go+++ b/docs/docs.go@@ -23489,10 +23489,6 @@ const docTemplate = `{"description": "GeneratedPassword is the plaintext password when the server\nauto-generated one. Absent when the caller supplied the password.","type": "string"},- "idempotent": {- "description": "Idempotent is true when the identity already existed (HTTP 200).\nThe SPA axios interceptor discards status codes, so this flag is\nthe body-level signal that nothing was created or changed.",- "type": "boolean"- },"user": {"$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo"}diff --git a/docs/swagger.json b/docs/swagger.jsonindex 0f7ac47d5..4ce7bff11 100644--- a/docs/swagger.json+++ b/docs/swagger.json@@ -23482,10 +23482,6 @@"description": "GeneratedPassword is the plaintext password when the server\nauto-generated one. Absent when the caller supplied the password.","type": "string"},- "idempotent": {- "description": "Idempotent is true when the identity already existed (HTTP 200).\nThe SPA axios interceptor discards status codes, so this flag is\nthe body-level signal that nothing was created or changed.",- "type": "boolean"- },"user": {"$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo"}diff --git a/docs/swagger.yaml b/docs/swagger.yamlindex 2f163288e..572ac1933 100644--- a/docs/swagger.yaml+++ b/docs/swagger.yaml@@ -5064,12 +5064,6 @@ definitions:GeneratedPassword is the plaintext password when the serverauto-generated one. Absent when the caller supplied the password.type: string- idempotent:- description: |-- Idempotent is true when the identity already existed (HTTP 200).- The SPA axios interceptor discards status codes, so this flag is- the body-level signal that nothing was created or changed.- type: booleanuser:$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo'type: objectdiff --git a/internal/handler/system.go b/internal/handler/system.goindex e481ace7a..cee7f54d8 100644--- a/internal/handler/system.go+++ b/internal/handler/system.go@@ -1596,10 +1596,6 @@ type CreateSystemUserResponse struct {// GeneratedPassword is the plaintext password when the server// auto-generated one. Absent when the caller supplied the password.GeneratedPassword string `json:"generated_password,omitempty"`- // Idempotent is true when the identity already existed (HTTP 200).- // The SPA axios interceptor discards status codes, so this flag is- // the body-level signal that nothing was created or changed.- Idempotent bool `json:"idempotent,omitempty"`}// CreateSystemUser godoc@@ -1658,7 +1654,7 @@ func (h *SystemHandler) CreateSystemUser(c *gin.Context) {"password_generated": false,"idempotent": true,})- c.JSON(http.StatusOK, CreateSystemUserResponse{User: user.ToUserInfo(), Idempotent: true})+ c.JSON(http.StatusOK, CreateSystemUserResponse{User: user.ToUserInfo()})case errors.Is(err, service.ErrPasswordPolicy):c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})case errors.Is(err, service.ErrUserIdentityConflict):diff --git a/internal/handler/system_user_create_test.go b/internal/handler/system_user_create_test.goindex 78e5c719b..4b9af3cbf 100644--- a/internal/handler/system_user_create_test.go+++ b/internal/handler/system_user_create_test.go@@ -91,9 +91,6 @@ func TestCreateSystemUserCreatesUserWithExplicitPassword(t *testing.T) {resp.GeneratedPassword,)}- if resp.Idempotent {- t.Fatal("fresh create must not set idempotent")- }if users.gotReq == nil || users.gotReq.Password == nil || *users.gotReq.Password != "PlainPass9" {t.Fatalf("service received unexpected request: %+v", users.gotReq)}@@ -136,9 +133,6 @@ func TestCreateSystemUserAutoGeneratesPasswordWhenEmpty(t *testing.T) {if resp.GeneratedPassword != "G3n3r4t3dP4ssw0rd" {t.Fatalf("generated_password=%q, want the once-only generated password", resp.GeneratedPassword)}- if resp.Idempotent {- t.Fatal("fresh auto-generate create must not set idempotent")- }if users.gotReq == nil || users.gotReq.Password != nil {t.Fatalf("absent password must reach the service as nil, got %+v", users.gotReq)}@@ -266,9 +260,6 @@ func TestCreateSystemUserDuplicateIdentityReturnsExistingUser(t *testing.T) {if resp.GeneratedPassword != "" {t.Fatalf("generated_password=%q, want empty for an existing user", resp.GeneratedPassword)}- if !resp.Idempotent {- t.Fatal("duplicate identity 200 must set idempotent=true so the SPA can tell it from a 201")- }if len(audits.entries) != 1 || audits.entries[0].Action != types.AuditActionSystemUserCreated {t.Fatalf("expected one %s audit entry, got %+v", types.AuditActionSystemUserCreated, audits.entries)}