Inconsistent source of status for ApplicationCall#respond variants
- Dominant language
- Kotlin
- Stars
- 14.5k
- Forks
- 1.3k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 49
Description
Given the following code:
` call.respond(HttpStatusCode.InternalServerError, "{}")
`
` call.respondText("{}", ContentType.Application.Json, HttpStatusCode.InternalServerError)
`
I am intercepting the response in the 'after' of the 'sendPipeline':
```
pipeline.sendPipeline.intercept(ApplicationSendPipeline.After) {
println("Respond: " + context.response.status())
println("Respond TextContent: " + (this.subject as? TextContent)?.status)
}
```
The results for this interceptor are as following:
Usecase | Code | `ApplicationResponse#status()` | `TextContent#status`
--- | --- | --- | ---
1 | `call.respond(HttpStatusCode.InternalServerError, "{}")` | `500 Internal Server Error`| `null`
2 | `call.respondText("{}", ContentType.Application.Json, HttpStatusCode.InternalServerError)` | `null`| `500 Internal Server Error`
Perhaps it is logical that usecase 1 has a null value for `TextContent#status` because it is not an actual `TextContent`. However, I would expect for usecase 2 that `ApplicationResponse#status()` would be set.
**tl;dr:** There is no single source of truth for getting the statuscode (which I would expect to be `ApplicationResponse#status()`.
Contributor guide
Research direction
Start from the ApplicationCall.respond and respondText entry points and trace how each value reaches the sendPipeline After interceptor. Compare ApplicationResponse#status() with TextContent#status for both examples, then verify that one consistent status source is available for both response variants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100