Hello, we’re observing 404 not found errors when c...
# talk-kratos
w
Hello, we’re observing 404 not found errors when calling the DeleteIdentity Admin API with the golang sdk. We had it working in a separate configuration with
--dev
but once we removed it we started getting these errors. Does anyone know what might be happening?
w
404 doesnt make much sense, I think you are accidentally targeting the public API and not the admin API
w
Copy code
response, err := c.client.IdentityApi.DeleteIdentity(c.withAdminContext(ctx), userID).Execute()
^ The call looks like this
Copy code
func (c *kratosClient) withAdminContext(ctx context.Context) context.Context {
	return context.WithValue(ctx, kratos.ContextServerVariables, map[string]string{"host": c.adminAddress})
}
^ definition of
withAdminContext
Copy code
configuration := kratos.NewConfiguration()
	configuration.Servers = []kratos.ServerConfiguration{
		{
			URL: "{host}",
			Variables: map[string]kratos.ServerVariable{
				"host": {
					Description:  "Host, default public",
					DefaultValue: publicKratosAddress,
				},
			},
		},
	}
configuration is setup like that
w
I am not familiar with the Go SDK but double check your admin API endpoint
I think you are targeting the public API
w
Do you know what changes w.r.t to the admin API when
--dev
is removed from the kratos startup flags?
w
I am not sure but I don't think it effects the admin API, I think it does disable strict mode on the cookies on the public API or at least something with allowing http
s
I guess you are trying to delete an identity that does not exist anymore? What is the full error, and what do the server logs say?
w
404 page not found
is the response body and
undefined response type
is the
err
we’re getting back in the golang sdk
I tried enabling
--dev
again to see if it would work, but it’s the same result
I tired creating a separate client for the admin server and logged it as well and that doesn’t change anything either
s
do you have something running in front of kratos? maybe that is not setup correctly and returns a 404 instead of forwarding
server logs would be helpful
w
Copy code
time=2023-04-17T13:53:21Z level=info msg=started handling request http_request=map[headers:map[accept:application/json accept-encoding:gzip user-agent:OpenAPI-Generator/1.0.0/go] host:ory-kratos:4434 method:DELETE path:/admin/identities/ query:<nil> remote:10.192.215.101:49894 scheme:http]
time=2023-04-17T13:53:21Z level=info msg=completed handling request http_request=map[headers:map[accept:application/json accept-encoding:gzip user-agent:OpenAPI-Generator/1.0.0/go] host:ory-kratos:4434 method:DELETE path:/admin/identities/ query:<nil> remote:10.192.215.101:49894 scheme:http] http_response=map[headers:map[content-type:text/plain; charset=utf-8 x-content-type-options:nosniff] size:19 status:404 text_status:Not Found took:258.56µs]
It’s kubernetes
s
try setting the log-level to trace or at least debug
ah but the path does not contain the id
w
ah must be sending an empty string, thanks
s
the path should be
/admin/identities/whatever-id
184 Views