apache / incubator-devlake

Apache DevLake is an open-source dev data platform to ingest, analyze, and visualize the fragmented data from DevOps tools, extracting insights for engineering excellence, developer experience, and community growth.
https://devlake.apache.org/
Apache License 2.0
2.5k stars 493 forks source link

[Bug][devlake] Exception while adding Workspaces through Tapd connection #7135

Open assert6 opened 4 months ago

assert6 commented 4 months ago

Search before asking

What happened

image

What do you expect to happen

2024/03/07 07:39:22 http: panic serving 172.19.0.5:42518: reflect: call of reflect.Value.Field on zero Value
goroutine 146003 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1854 +0xbf
panic({0x16aeb20, 0xc00387ca50})
        /usr/local/go/src/runtime/panic.go:890 +0x270
reflect.Value.Field({0x0?, 0x0?, 0x7f54195a5a2e?}, 0xa?)
        /usr/local/go/src/reflect/value.go:1268 +0xe5
github.com/apache/incubator-devlake/helpers/pluginhelper/api.returnPrimaryKeyValue({0x7f5419946920, 0x0})
        /app/helpers/pluginhelper/api/scope_generic_helper.go:484 +0x17f
github.com/apache/incubator-devlake/helpers/pluginhelper/api.(*GenericScopeApiHelper[...]).validatePrimaryKeys(0x7f5419a106c0?, {0xc0024f3830, 0x2, 0x16c5880})
        /app/helpers/pluginhelper/api/scope_generic_helper.go:517 +0x111
github.com/apache/incubator-devlake/helpers/pluginhelper/api.(*GenericScopeApiHelper[...]).PutScopes(0x7f5419a106c0, 0xc00387c888, {0xc0024f3830?, 0x2?, 0x2})
        /app/helpers/pluginhelper/api/scope_generic_helper.go:170 +0xd5
github.com/apache/incubator-devlake/helpers/pluginhelper/api.(*ScopeApiHelper[...]).Put(0x7f5419a05100, 0xc003a8cae0)
        /app/helpers/pluginhelper/api/scope_helper.go:67 +0x137
github.com/apache/incubator-devlake/plugins/tapd/api.PutScope(0xc003a8ca50?)
        /app/plugins/tapd/api/scope.go:48 +0x30
github.com/apache/incubator-devlake/server/api.handlePluginCall.func1(0xc001e82200)
        /app/server/api/router.go:135 +0x30f
github.com/gin-gonic/gin.(*Context).Next(...)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/apache/incubator-devlake/server/api.OAuth2ProxyAuthentication.func1(0xc001e82200)
        /app/server/api/middlewares.go:94 +0x143
github.com/gin-gonic/gin.(*Context).Next(...)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/apache/incubator-devlake/server/api.RestAuthentication.func1(0xc001e82200)
        /app/server/api/middlewares.go:114 +0xcc2
github.com/gin-gonic/gin.(*Context).Next(...)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc002e0da00, 0xc001e82200)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x66b
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc002e0da00, {0x1ab8670?, 0xc0033f4700}, 0xc001e82000)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1dd
net/http.serverHandler.ServeHTTP({0x1ab2ac8?}, {0x1ab8670, 0xc0033f4700}, 0xc001e82000)
        /usr/local/go/src/net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc0007bc5a0, {0x1ab9630, 0xc00141c390})
        /usr/local/go/src/net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3089 +0x5ed
2024/03/07 07:39:23 http: panic serving 172.19.0.5:42522: reflect: call of reflect.Value.Field on zero Value
goroutine 146007 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1854 +0xbf
panic({0x16aeb20, 0xc00306ec30})
        /usr/local/go/src/runtime/panic.go:890 +0x270
reflect.Value.Field({0x0?, 0x0?, 0x7f54195a5a2e?}, 0xa?)
        /usr/local/go/src/reflect/value.go:1268 +0xe5
github.com/apache/incubator-devlake/helpers/pluginhelper/api.returnPrimaryKeyValue({0x7f5419946920, 0x0})
        /app/helpers/pluginhelper/api/scope_generic_helper.go:484 +0x17f
github.com/apache/incubator-devlake/helpers/pluginhelper/api.(*GenericScopeApiHelper[...]).validatePrimaryKeys(0x7f5419a106c0?, {0xc002fb7660, 0x2, 0x16c5880})
        /app/helpers/pluginhelper/api/scope_generic_helper.go:517 +0x111
github.com/apache/incubator-devlake/helpers/pluginhelper/api.(*GenericScopeApiHelper[...]).PutScopes(0x7f5419a106c0, 0xc00306e990, {0xc002fb7660?, 0x2?, 0x2})
        /app/helpers/pluginhelper/api/scope_generic_helper.go:170 +0xd5
github.com/apache/incubator-devlake/helpers/pluginhelper/api.(*ScopeApiHelper[...]).Put(0x7f5419a05100, 0xc0024b2660)
        /app/helpers/pluginhelper/api/scope_helper.go:67 +0x137
github.com/apache/incubator-devlake/plugins/tapd/api.PutScope(0xc0024b25d0?)
        /app/plugins/tapd/api/scope.go:48 +0x30
github.com/apache/incubator-devlake/server/api.handlePluginCall.func1(0xc003234700)
        /app/server/api/router.go:135 +0x30f
github.com/gin-gonic/gin.(*Context).Next(...)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/apache/incubator-devlake/server/api.OAuth2ProxyAuthentication.func1(0xc003234700)
        /app/server/api/middlewares.go:94 +0x143
github.com/gin-gonic/gin.(*Context).Next(...)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/apache/incubator-devlake/server/api.RestAuthentication.func1(0xc003234700)
        /app/server/api/middlewares.go:114 +0xcc2
github.com/gin-gonic/gin.(*Context).Next(...)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc002e0da00, 0xc003234700)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x66b
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc002e0da00, {0x1ab8670?, 0xc000732540}, 0xc003234200)
        /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1dd
net/http.serverHandler.ServeHTTP({0x1ab2ac8?}, {0x1ab8670, 0xc000732540}, 0xc003234200)
        /usr/local/go/src/net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc0007bcb40, {0x1ab9630, 0xc00141c390})
        /usr/local/go/src/net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3089 +0x5ed

How to reproduce

stable reproducing

Anything else

No response

Version

devlake:v0.20.0

Are you willing to submit PR?

Code of Conduct

d4x1 commented 3 months ago

You can try to use the latest version. I think it has been updated. @assert6

assert6 commented 3 months ago

I tried version 0.21 but still reported this error

d4x1 commented 3 months ago

It's weird. I have do the same operation on devlake release-v0.21(commit: 89a845947), and it works for me. Can you paste the request with curl format? And you can try another tapd company or workspace, and see what will happen.

assert6 commented 3 months ago

image

curl 'http://localhost:4000/api/plugins/tapd/connections/1/scopes' \
  -X 'PUT' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Accept-Language: zh-CN,zh;q=0.9,zh-TW;q=0.8,en-US;q=0.7,en;q=0.6' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: Phpstorm-275dc04a=4df47315-30fb-43e2-9e84-a51f8e834835' \
  -H 'Origin: http://localhost:4000' \
  -H 'Referer: http://localhost:4000/connections/tapd/1' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  --data-raw '{"data":[null,{"createdAt":"0001-01-01T00:00:00Z","updatedAt":"0001-01-01T00:00:00Z","_raw_data_params":"","_raw_data_table":"","_raw_data_id":0,"_raw_data_remark":"","connectionId":0,"id":"63835346","name":"T5","pretty_name":"63835346","category":"","status":"normal","description":"T5","begin_date":null,"end_date":null,"external_on":"","parent_id":"22912571","creator":"T5李林森 (lilinsen@addcn.com)","created":{}}]}'

I found a strange null in the curl body

assert6 commented 3 months ago

fa63496c52a1e3859f47e052ee5eceb

When the project and group have the same name, it will be repeated

github-actions[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.