{"record":{"id":"855b1c0ceee4db0c","repo":"Tencent/WeKnora","slug":"failed-to-update-mcp-service-w","errorCode":null,"errorMessage":"failed to update MCP service: %w","messagePattern":"failed to update MCP service: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/mcp_service.go","lineNumber":576,"sourceCode":"\t\tif existing.AuthConfig.APIKey != \"\" {\n\t\t\texisting.AuthConfig.APIKey = \"\"\n\t\t\tchanged = true\n\t\t}\n\tcase \"token\":\n\t\tif existing.AuthConfig.Token != \"\" {\n\t\t\texisting.AuthConfig.Token = \"\"\n\t\t\tchanged = true\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown credential field: %s\", field)\n\t}\n\tif !changed {\n\t\treturn nil\n\t}\n\n\texisting.UpdatedAt = time.Now()\n\tif err := s.mcpServiceRepo.Update(ctx, existing); err != nil {\n\t\treturn fmt.Errorf(\"failed to update MCP service: %w\", err)\n\t}\n\n\ts.mcpManager.CloseClient(id)\n\tlogger.GetLogger(ctx).Infof(\n\t\t\"MCP credential cleared by user: id=%s field=%s, connection closed\",\n\t\tsecutils.SanitizeForLog(id), field,\n\t)\n\treturn nil\n}\n\n// GetMCPServiceResources retrieves the list of resources from an MCP service\nfunc (s *mcpServiceService) GetMCPServiceResources(\n\tctx context.Context,\n\ttenantID uint64,\n\tid string,\n) ([]*types.MCPResource, error) {\n\t// Get service\n\tservice, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)","sourceCodeStart":558,"sourceCodeEnd":594,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/mcp_service.go#L558-L594","documentation":"Thrown by ClearMCPCredential when mcpServiceRepo.Update fails to persist the credential change (after the field was cleared in memory). A database write failure; on success the client connection is also closed to force reconnect.","triggerScenarios":"Thrown at internal/application/service/mcp_service.go:576 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check database connectivity and retry the clear request","Verify the service row was not concurrently deleted","Retry is safe: the operation is idempotent for already-empty fields"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}