canonical / identity-platform-admin-ui

Admin UI for the Canonical identity broker and identity provider solution
Other
5 stars 4 forks source link

Error on creation of a schema via POST #254

Closed edlerd closed 3 months ago

edlerd commented 3 months ago

Environment: Running latest/edge of the juju deployment of the identity platform with the admin-ui build from current master.

We created a new schema via API


curl -d '{
   "schema":{
      "$id":"https://schemas.canonical.com/presets/kratos/test_v0.json",
      "$schema":"http://json-schema.org/draft-07/schema#",
      "title":"Admin Account",
      "type":"object",
      "properties":{
         "traits":{
            "type":"object",
            "properties":{
               "username":{
                  "type":"string",
                  "title":"Username",
                  "ory.sh/kratos":{
                     "credentials":{
                        "password":{
                           "identifier":true
                        }
                     }
                  }
               }
            }
         }
      },
      "additionalProperties":true
   }
}' -X POST -H 'Content-Type: application/json' http://127.0.0.1:8000/api/v0/schemas

Got an empty response from the API. The logs of admin-ui revealed this trace:

2024/03/28 11:36:59 http: panic serving 127.0.0.1:41558: assignment to entry in nil map
goroutine 39 [running]:
net/http.(*conn).serve.func1()
        /snap/go/10554/src/net/http/server.go:1868 +0xb9
panic({0x19dbb00?, 0x1f425f0?})
        /snap/go/10554/src/runtime/panic.go:920 +0x270
github.com/canonical/identity-platform-admin-ui/pkg/schemas.(*Service).CreateSchema(0xc0004b4cb0, {0x1f62930?, 0xc000d04360?}, 0xc00098a060)
        /root/parts/go-build/build/pkg/schemas/service.go:200 +0x448
github.com/canonical/identity-platform-admin-ui/pkg/schemas.(*API).handleCreate(0xc0005a34c0, {0x1f56f00, 0xc0005c4240}, 0xc0000b8b00)
        /root/parts/go-build/build/pkg/schemas/handlers.go:189 +0x30d
net/http.HandlerFunc.ServeHTTP(0xc0000b8900?, {0x1f56f00?, 0xc0005c4240?}, 0x1f417f0?)
        /snap/go/10554/src/net/http/server.go:2136 +0x29
github.com/canonical/identity-platform-admin-ui/pkg/web.NewRouter.(*Middleware).Authorize.func4.1({0x1f56f00, 0xc0005c4240}, 0x0?)
        /root/parts/go-build/build/internal/authorization/middlewares.go:193 +0x28b
net/http.HandlerFunc.ServeHTTP(0xc000626c80?, {0x1f56f00?, 0xc0005c4240?}, 0x0?)
        /snap/go/10554/src/net/http/server.go:2136 +0x29
github.com/go-chi/chi/v5.(*ChainHandler).ServeHTTP(0x19c2940?, {0x1f56f00?, 0xc0005c4240?}, 0xc000d0e005?)
        /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.10/chain.go:31 +0x26
github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc0005c4360, {0x1f56f00, 0xc0005c4240}, 0xc0000b8900)
        /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.10/mux.go:444 +0x2b4
net/http.HandlerFunc.ServeHTTP(0x1f62930?, {0x1f56f00?, 0xc0005c4240?}, 0x2e63c70?)
        /snap/go/10554/src/net/http/server.go:2136 +0x29
github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc0005c4360, {0x1f56f00, 0xc0005c4240}, 0xc0000b8700)
        /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.10/mux.go:90 +0x315
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.(*middleware).serveHTTP(0xc000aa9c30, {0x1f553b8?, 0xc0007fe0e0}, 0xc0000b8500, {0x1f454a0, 0xc0005c4360})
        /root/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@v0.45.0/handler.go:217 +0x1202
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.NewMiddleware.func1.1({0x1f553b8?, 0xc0007fe0e0?}, 0xc0004b6090?)
        /root/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@v0.45.0/handler.go:81 +0x35
net/http.HandlerFunc.ServeHTTP(0x410965?, {0x1f553b8?, 0xc0007fe0e0?}, 0xc0007fe001?)
        /snap/go/10554/src/net/http/server.go:2136 +0x29
net/http.serverHandler.ServeHTTP({0x1f4ea10?}, {0x1f553b8?, 0xc0007fe0e0?}, 0x6?)
        /snap/go/10554/src/net/http/server.go:2938 +0x8e
net/http.(*conn).serve(0xc00081c000, {0x1f62930, 0xc000800210})
        /snap/go/10554/src/net/http/server.go:2009 +0x5f4
created by net/http.(*Server).Serve in goroutine 11
        /snap/go/10554/src/net/http/server.go:3086 +0x5cb
syncronize-issues-to-jira[bot] commented 3 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/IAM-783.

This message was autogenerated