`HttpResponseValidator{}` doesn't work anymore in ...
# ktor
a
HttpResponseValidator{}
doesn't work anymore in 1.5.0, why? It doesn't get called at all https://ktor.io/docs/response-validation.html
there is already an opened issue: https://youtrack.jetbrains.com/issue/KTOR-1616
but it still doesn't work
r
1. make sure that you don’t overwrite
expectSuccess
in client config with
false
2. custom validations happens AFTER default validation. so if you want to handle non 200 status, your validator will not be called, because default one already threw exception
the issue that you send is closed and you can read comments for more details
a
but I don't want anything by default, I already have code which handles this but this isn't an option anymore?
meaning I don't need default validation
so there is no way to avoid default validation?
what's the point of
validateResponse
if it doesn't get called
yeah there are comments in the ticket but still a breaking change
r
there are three use cases for custom validation: 1. you want more strict validation of 200 responses - it works with default validation 2. you want different handling of non 200 responses - you can use
handleResponseException
with minor code change 3. you want less strict validation - this is not supported, because it’s how feature is meant to be used. Previous behaviour was wrong
a
ok thanks when you say
Previous behaviour was wrong
you mean on how ktor handled validation before
1.5.0
r
yes, that’s correct. if you will write your use case, I can help you with the migration
a
thanks, already done basically
HttpResponse
is now wrapped within
ClientRequestException
and that's what my logic relied on
👍 1