API : teams query #746

Closed
opened 2025-11-02 03:35:01 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @camlafit on GitHub (May 25, 2017).

  • Gitea version (or commit ref): master and 1.1.1
  • Git version:
  • Operating system: Debian Jessie
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

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
Originally created by @camlafit on GitHub (May 25, 2017). - Gitea version (or commit ref): master and 1.1.1 - Git version: - Operating system: Debian Jessie - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## 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 ```
GiteaMirror added the type/bugmodifies/api labels 2025-11-02 03:35:01 -06:00
Author
Owner

@ethantkoenig commented on GitHub (May 25, 2017):

@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)

@ethantkoenig commented on GitHub (May 25, 2017): @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)
Author
Owner

@camlafit commented on GitHub (May 26, 2017):

Hi

No more 500 on second query, but now 404

  • TOKEN is related an admin account (and is set in team)
  • USERNAME is an active account create by PUT admin/users api

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

User related to token is

  • listed on GET /api/v1/teams/3/members
  • 404 on GET /api/v1/teams/3/members/$USERNAME_TOKEN
  • 204 on PUT /api/v1/teams/3/members/$USERNAME_TOKEN

Username is

  • 204 on PUT /api/v1/teams/3/members/$USERNAME
  • 404 on GET /api/v1/teams/3/members/$USERNAME
  • listed on GET /api/v1/teams/3/members
@camlafit commented on GitHub (May 26, 2017): Hi No more 500 on second query, but now 404 * TOKEN is related an admin account (and is set in team) * USERNAME is an active account create by PUT admin/users api Thirth query looks ok now, user is set to team. User related to token is * listed on GET /api/v1/teams/3/members * 404 on GET /api/v1/teams/3/members/$USERNAME_TOKEN * 204 on PUT /api/v1/teams/3/members/$USERNAME_TOKEN Username is * 204 on PUT /api/v1/teams/3/members/$USERNAME * 404 on GET /api/v1/teams/3/members/$USERNAME * listed on GET /api/v1/teams/3/members
Author
Owner

@ethantkoenig commented on GitHub (May 26, 2017):

@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.

@ethantkoenig commented on GitHub (May 26, 2017): @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.
Author
Owner

@camlafit commented on GitHub (May 26, 2017):

Hi

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

  • Looks to miss GET /api/v1/teams/:teamid/members/$USERNAME , should be return data about this username
  • Looks to miss GET /api/v1/teams/ , should be return teams list affect to the user query

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

@camlafit commented on GitHub (May 26, 2017): Hi Ok understood, looks normal and this issue should be set as solved, but I've two others questions directly related : * Looks to miss GET /api/v1/teams/:teamid/members/$USERNAME , should be return data about this username * Looks to miss GET /api/v1/teams/ , should be return teams list affect to the user query And about admin usage (get all teams, ...) , should be set in /api/v1/admin/ part
Author
Owner

@lunny commented on GitHub (May 26, 2017):

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

@lunny commented on GitHub (May 26, 2017): @camlafit maybe you can fire another issue or maybe there is already an issue to describe it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#746