Erro to get tenantByApiKey

38 views
Skip to first unread message

Alexandre Rocha

unread,
Apr 27, 2021, 4:17:05 PM4/27/21
to Kill Bill users mailing-list
Hello Folks,
I'm try to use the killbill api to find a tenant using his apiKey information. The Swagger specification of this endpoint shows that it should return a "404 Tenant not found " in case the tenant is not in the database record. But when I call the endpoint with a non-existing apiKey the response is "500 Internal server Error". 

Here is my request sample and the response that I got:

curl -X GET --header 'Accept: application/json' 'https://${host}:${post}/1.0/kb/tenants?apiKey=123455'

Response:
Http status : 500 
Response body: 
 {
    "className": "java.lang.RuntimeException",
    "code": null,
    "message": "java.lang.IllegalStateException: TenantCacheLoader cannot find value for key 12345",
    "causeClassName": "java.lang.IllegalStateException",
    "causeMessage": "TenantCacheLoader cannot find value for key 12345",
    "stackTrace": []
}


Is this right? Or Am I sending the wrong request ?

stephane brossier

unread,
Apr 27, 2021, 8:10:48 PM4/27/21
to Alexandre Rocha, Kill Bill users mailing-list
Alexandre,

Seems like a bug indeed.

Stéphane


--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/killbilling-users/93189e9e-2534-4c95-a86a-cbcf17d66470n%40googlegroups.com.

Alexandre Rocha

unread,
Apr 28, 2021, 10:01:00 AM4/28/21
to Kill Bill users mailing-list
Is there another endpoint that you guys recommend to use to check if a tenant exists using the apiKey? 

stephane brossier

unread,
Apr 29, 2021, 9:35:26 PM4/29/21
to Alexandre Rocha, Kill Bill users mailing-list
Digging deeper, this is actually an old issue we have not had time to address: https://github.com/killbill/killbill/issues/902

I would say if the call does not return 200, then it means the tenant does not exist -- in reality you could have a real 500 error, i.e your DB is down and Kill Bill fails to access it -- but in practise call very rarely return 500. If you want to improve on the workaround you could use the json returned in the error:

< HTTP/1.1 500 Internal Server Error
< Date: Wed, 28 Apr 2021 00:09:48 GMT
< Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Tue, 27-Apr-2021 00:09:48 GMT
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS
< Access-Control-Allow-Headers: Authorization,Content-Type,Location,X-Killbill-ApiKey,X-Killbill-ApiSecret,X-Killbill-Comment,X-Killbill-CreatedBy,X-Killbill-Pagination-CurrentOffset,X-Killbill-Pagination-MaxNbRecords,X-Killbill-Pagination-NextOffset,X-Killbill-Pagination-NextPageUri,X-Killbill-Pagination-TotalNbRecords,X-Killbill-Reason
< Access-Control-Expose-Headers: Authorization,Content-Type,Location,X-Killbill-ApiKey,X-Killbill-ApiSecret,X-Killbill-Comment,X-Killbill-CreatedBy,X-Killbill-Pagination-CurrentOffset,X-Killbill-Pagination-MaxNbRecords,X-Killbill-Pagination-NextOffset,X-Killbill-Pagination-NextPageUri,X-Killbill-Pagination-TotalNbRecords,X-Killbill-Reason
< Access-Control-Allow-Credentials: true
< Content-Type: application/json
< Vary: Accept-Encoding
< Content-Length: 285
< Server: Jetty(9.4.36.v20210114)
<
* Connection #0 to host 127.0.0.1 left intact
{"className":"java.lang.RuntimeException","code":null,"message":"java.lang.IllegalStateException: TenantCacheLoader cannot find value for key 123455","causeClassName":"java.lang.IllegalStateException","causeMessage":"TenantCacheLoader cannot find value for key 123455","stackTrace":[]}* Closing connection 0



Reply all
Reply to author
Forward
0 new messages