go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.6k stars 5.45k forks source link

API : teams query #1809

Closed camlafit closed 7 years ago

camlafit commented 7 years ago

Description

Following url provided by api/v1/api.go, I've try to get teams informations and set members to team. I've tried with 1.1.1 and master version on 386 arch

Query tested :

curl -H 'Authorization: token $TOKEN' -X GET "https://$GITEA_SERVER/api/v1/teams/"
curl -H 'Authorization: token $TOKEN' -X GET "https://$GITEA_SERVER/api/v1/teams/3"
curl -H 'Authorization: token $TOKEN' -X PUT "https://$GITEA_SERVER/api/v1/teams/3/members/$USERNAME"

1/ With first query log shown :

[Macaron] 2017-05-25 08:49:58: Started GET /api/v1/teams for 88.190.92.83
[Macaron] 2017-05-25 08:49:58: Completed /api/v1/teams 404 Not Found in 10.363091ms

Looks logical any endpoint looks defined, but get all teams should be a plus

2/ With second query log shown :

[Macaron] 2017-05-25 08:49:35: Started GET /api/v1/teams/3/ for IP
[Macaron] PANIC: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:489 (0x433c0f)
        gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/go/src/runtime/panic.go:63 (0x432abe)
        panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:290 (0x44928f)
        sigpanic: panicmem()
/root/GO/src/code.gitea.io/gitea/routers/api/v1/api.go:155 (0x10616aa)
/usr/local/go/src/runtime/asm_amd64.s:514 (0x460ca8)
        call32: CALLFN(·call32, 32)
/usr/local/go/src/reflect/value.go:434 (0x4c344f)
        Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:302 (0x4c2a14)
        Value.Call: return v.call("Call", in)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x85dfdf)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x85d9aa)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:113 (0x88aca2)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:104 (0x88abc6)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/session/session.go:186 (0x8e2300)
/usr/local/go/src/runtime/asm_amd64.s:514 (0x460ca8)
        call32: CALLFN(·call32, 32)
/usr/local/go/src/reflect/value.go:434 (0x4c344f)
        Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:302 (0x4c2a14)
        Value.Call: return v.call("Call", in)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x85dfdf)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x85d9aa)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:113 (0x88aca2)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:104 (0x88abc6)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/recovery.go:161 (0x89dd2b)
/usr/local/go/src/runtime/asm_amd64.s:514 (0x460ca8)
        call32: CALLFN(·call32, 32)
/usr/local/go/src/reflect/value.go:434 (0x4c344f)
        Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:302 (0x4c2a14)
        Value.Call: return v.call("Call", in)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x85dfdf)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x85d9aa)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:113 (0x88aca2)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:104 (0x88abc6)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/logger.go:43 (0x89cfe4)
/usr/local/go/src/runtime/asm_amd64.s:514 (0x460ca8)
        call32: CALLFN(·call32, 32)
/usr/local/go/src/reflect/value.go:434 (0x4c344f)
        Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:302 (0x4c2a14)
        Value.Call: return v.call("Call", in)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x85dfdf)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x85d9aa)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:113 (0x88aca2)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/router.go:184 (0x89eff9)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/router.go:288 (0x8970dd)
/root/GO/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/macaron.go:177 (0x88f10c)
/root/GO/src/code.gitea.io/gitea/vendor/github.com/gorilla/context/context.go:141 (0xaca22b)
/usr/local/go/src/net/http/server.go:1942 (0x6dba34)
        HandlerFunc.ServeHTTP: f(w, r)
/usr/local/go/src/net/http/server.go:2568 (0x6de2f2)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1825 (0x6da5a2)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:2197 (0x463461)
        goexit: BYTE    $0x90   // NOP
[Macaron] 2017-05-25 08:51:48: Completed /api/v1/teams/3 500 Internal Server Error in 23.696434ms

3/ With third query

[Macaron] 2017-05-25 08:53:17: Started GET /api/v1/teams/3/members/$USERNAME for IP
[Macaron] 2017-05-25 08:53:17: Completed /api/v1/teams/3/members/$USERNAME 404 Not Found in 11.908173ms
ethantkoenig commented 7 years ago

@camlafit #1811 fixes the second query. The third query should return a 404 if $USERNAME is not an actual username, or if that user is not a member of the team (see https://developer.github.com/v3/orgs/teams/#get-team-member)

camlafit commented 7 years ago

Hi

No more 500 on second query, but now 404

Thirth query looks ok now, user is set to team.

User related to token is

Username is

ethantkoenig commented 7 years ago

@camlafit If the user authenticated by $TOKEN is not a member of whatever organization team 3 belongs to, then GET /api/v1/teams/3 should return a 404.

camlafit commented 7 years ago

Hi

Ok understood, looks normal and this issue should be set as solved, but I've two others questions directly related :

And about admin usage (get all teams, ...) , should be set in /api/v1/admin/ part

lunny commented 7 years ago

@camlafit maybe you can fire another issue or maybe there is already an issue to describe it.