keon94 opened a new issue, #4240:
URL: https://github.com/apache/incubator-devlake/issues/4240

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   I was testing out Jenkins, and decided to add a new job to scopes. It throws:
   ```
   time="2023-01-19 19:36:04" level=info 
msg="/mnt/c/Users/Keon/Dev/Shared/lake/backend/impls/dalgorm/dalgorm.go:180
 Error 1062: Duplicate entry 
'Jenkins-Local-Project-cicd_scopes-jenkins:JenkinsJob:3:test-fold' for key 
'project_mapping.PRIMARY'
   [0.497ms] [rows:0] INSERT INTO `project_mapping` 
(`project_name`,`table`,`row_id`,`created_at`,`updated_at`,`_raw_data_params`,`_raw_data_table`,`_raw_data_id`,`_raw_data_remark`)
 VALUES 
('Jenkins-Local-Project','cicd_scopes','jenkins:JenkinsJob:3:test-folder/basic-job','2023-01-19
 19:36:04.415','2023-01-19 19:36:04.415','','',0,'')"
   time="2023-01-19 19:36:04" level=error msg="HTTP 400 error
        caused by: attached stack trace
          -- stack trace:
          | github.com/apache/incubator-devlake/server/api/blueprints.Patch
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/api/blueprints/blueprints.go:159
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:99
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.LoggerWithConfig.func1
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
          |     /home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:555
          | github.com/gin-gonic/gin.(*Engine).ServeHTTP
          |     /home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:511
          | net/http.serverHandler.ServeHTTP
          |     /home/keon/go/src/net/http/server.go:2947
          | net/http.(*conn).serve
          |     /home/keon/go/src/net/http/server.go:1991
        Wraps: (2) error patching the blueprint (400)
        Wraps: (3) attached stack trace
          -- stack trace:
          | github.com/apache/incubator-devlake/server/services.saveBlueprint
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint.go:163
          | github.com/apache/incubator-devlake/server/services.PatchBlueprint
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint.go:197
          | github.com/apache/incubator-devlake/server/api/blueprints.Patch
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/api/blueprints/blueprints.go:157
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:99
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.LoggerWithConfig.func1
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
          |     /home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:555
          | github.com/gin-gonic/gin.(*Engine).ServeHTTP
          |     /home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:511
          | net/http.serverHandler.ServeHTTP
          |     /home/keon/go/src/net/http/server.go:2947
          | net/http.(*conn).serve
          |     /home/keon/go/src/net/http/server.go:1991
        Wraps: (4) attached stack trace
          -- stack trace:
          | 
github.com/apache/incubator-devlake/server/services.validateBlueprintAndMakePlan
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint.go:149
          | [...repeated from below...]
        Wraps: (5) make plan for blueprint failed
        Wraps: (6) attached stack trace
          -- stack trace:
          | github.com/apache/incubator-devlake/impls/dalgorm.(*Dalgorm).Create
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/impls/dalgorm/dalgorm.go:180
          | 
github.com/apache/incubator-devlake/server/services.GeneratePlanJsonV200
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint_makeplan_v200.go:65
          | 
github.com/apache/incubator-devlake/server/services.MakePlanForBlueprint
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint.go:296
          | 
github.com/apache/incubator-devlake/server/services.validateBlueprintAndMakePlan
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint.go:147
          | github.com/apache/incubator-devlake/server/services.saveBlueprint
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint.go:161
          | github.com/apache/incubator-devlake/server/services.PatchBlueprint
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/services/blueprint.go:197
          | github.com/apache/incubator-devlake/server/api/blueprints.Patch
          |     
/mnt/c/Users/Keon/Dev/Shared/lake/backend/server/api/blueprints/blueprints.go:157
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:99
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.LoggerWithConfig.func1
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241
          | github.com/gin-gonic/gin.(*Context).Next
          |     
/home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:168
          | github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
          |     /home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:555
          | github.com/gin-gonic/gin.(*Engine).ServeHTTP
          |     /home/keon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:511
          | net/http.serverHandler.ServeHTTP
          |     /home/keon/go/src/net/http/server.go:2947
          | net/http.(*conn).serve
          |     /home/keon/go/src/net/http/server.go:1991
          | runtime.goexit
          |     /home/keon/go/src/runtime/asm_amd64.s:1594
        Wraps: (7) Error 1062: Duplicate entry 
'Jenkins-Local-Project-cicd_scopes-jenkins:JenkinsJob:3:test-fold' for key 
'project_mapping.PRIMARY
   ```
   
   ### What do you expect to happen
   
   No error.
   
   ### How to reproduce
   
   Reconfigure any project scope. This should be independent of Jenkins.
   
   ### Anything else
   
   Fix should be straightforward. Change [this 
line](https://github.com/apache/incubator-devlake/blob/e6021492cd935f29ad61475d13d326dba0074a44/backend/server/services/blueprint_makeplan_v200.go#L65)
 to use _CreateOrUpdate_ instead of _Create_.
   
   ### Version
   
   main
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to