klesh commented on code in PR #6146:
URL: 
https://github.com/apache/incubator-devlake/pull/6146#discussion_r1339483290


##########
backend/helpers/pluginhelper/api/ds_scope_api_helper.go:
##########
@@ -0,0 +1,99 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package api
+
+import (
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/core/plugin"
+       "github.com/apache/incubator-devlake/helpers/srvhelper"
+       "github.com/apache/incubator-devlake/server/api/shared"
+)
+
+type DsScopeApiHelper[C plugin.ToolLayerConnection, S plugin.ToolLayerScope, 
SC plugin.ToolLayerScopeConfig] struct {
+       *ModelApiHelper[S]
+       *srvhelper.ScopeSrvHelper[C, S, SC]
+}
+
+func NewDsScopeApiHelper[C plugin.ToolLayerConnection, S 
plugin.ToolLayerScope, SC plugin.ToolLayerScopeConfig](
+       basicRes context.BasicRes,
+       srvHelper *srvhelper.ScopeSrvHelper[C, S, SC],
+) *DsScopeApiHelper[C, S, SC] {
+       return &DsScopeApiHelper[C, S, SC]{
+               ModelApiHelper: NewModelApiHelper[S](basicRes, 
srvHelper.ModelSrvHelper, []string{"connectionId", "scopeId"}),
+               ScopeSrvHelper: srvHelper,
+       }
+}
+
+func (connApi *DsScopeApiHelper[C, S, SC]) GetPage(input 
*plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
+       pagination, err := ParsePagination[srvhelper.ScopePagination](input)
+       if err != nil {
+               return nil, errors.BadInput.Wrap(err, "failed to decode 
pathvars into pagination")
+       }
+       scopes, count, err := connApi.ScopeSrvHelper.GetScopesPage(pagination)
+       if err != nil {

Review Comment:
   I can't think of any case these information could possibly help when an 
error occurs:
   1. `page size`: it is already in the request query string, either it is 
illegal which is handled by the `parsePagination`, or Out-Of-Range which should 
be handled in the `parsePagination` function. In any case, `page size` is a 400 
User Input Error. outputting this information doesn't seem to be helpful.
   2. `page No`, same as above
   3. `types of generics`:  it is too obvious by looking at the `URL`. 
   
   In general, I don't think outputting any of the above variables would help, 
would you like to show a concrete example? Thanks.
   
   In the meantime, I would update the `parsePagination` to verify `page size` 
and `page no`
   
   



-- 
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: commits-unsubscr...@devlake.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to