question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Ktor + gradle plugin] 5.5.0 to 6.2.5 regression around Content-Length & Transfer-Encoding

See original GitHub issue

Library Version 6.2.5

Describe the bug This is likely not an expedia graphql bug, but it seems prudent to start here in case others run into this, or perhaps the maintainers here have more experience and can think of an elegant fix.

The short version is: version 5.x uses Ktor in a way where the Content-Length header is present when running the :graphqlIntrospectSchema task. Versions 6.x result in NO Content-Length header. From what I can see, the Ktor Apache engine + Jackson Ktor plugin never resolve a Content-Length, so the engine defaults to Transfer-Encoding: Chunked

While most request handlers probably don’t have issues with chunked encoding, we are using this library in a context where we have a 3rd party vendor whose GraphQL server does NOT handle chunked encoding, so this regression is causing us heartburn as we need to upgrade this library to be in lock-step other dependency upgrades (kotlin 1.7, spring, etc), and not be left behind.

We can work around this with static schema files we fetch from 5.x (the /sdl endpoint isn’t supported here, so we must use introspection) or other hacks, but it’s not ideal.

To Reproduce Steps to reproduce the behavior. Please provide:

  • Schema Configuration

This is happening in a very vanilla usage context, with a very simple graphql config like:

graphql {
    client {
        endpoint = "http://$host/graphql"
        packageName = "com.testingmyissue.graphql.generated"
        queryFileDirectory = "${project.projectDir}/src/main/resources/gql"
    }
}
  • Kotlin code used to generate the schema

Compare the request headers from a :graphqlIntrospectSchema request in version 5.5.0 to 6.2.5 (or probably any other minor versions).

Expected behavior

The above configs are left totally alone (but with a valid remote host, of course), and you can see the regression in this comparison, having changed only the gradle plugin version from 5.5.0 to 6.2.5:

Example 5.5.0 request headers:

POST /graphql HTTP/1.1 
Accept: application/json 
Accept-Charset: UTF-8 
User-Agent: Ktor client 
Content-Length: 1761 
Content-Type: application/json 
Host: [[omitted]]
Connection: Keep-Alive 

Example 6.2.5 request headers:

POST /graphql HTTP/1.1 
Accept: application/json 
Accept-Charset: UTF-8 
User-Agent: Ktor client 
Transfer-Encoding: chunked 
Content-Type: application/json 
Host: [[omitted]
Connection: Keep-Alive 

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dariuszkuccommented, Sep 22, 2022

Hello 👋 This is due to the change in behavior in Ktor v2.0. I opened up YouTrack KTOR-4904 issue to track it.

1reaction
dariuszkuccommented, Dec 9, 2022

@samuelAndalon I’ll find some time soon – when I get a PR up for it, do you think a 6.x release with Ktor 2.2.x is in the cards?

@maxpiepenbrink I don’t think it will work with 6.x release (we are using Kotlin 1.6 whereas Ktor is based on Kotlin 1.7 since v 2.1.0).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · ExpediaGroup/graphql-kotlin - GitHub
[Ktor + gradle plugin] 5.5.0 to 6.2.5 regression around Content-Length & Transfer-Encoding type: bug Something isn't working.
Read more >
WhatsNew 2.1 | Ktor Framework
Ktor Gradle Plugin (Ktor server) is incompatible with Android Gradle Plugin.
Read more >
Search Results - CVE
A vulnerability has been found in Activity Log Plugin and classified as critical. This vulnerability affects unknown code of the component HTTP Header...
Read more >
Libraries for running GraphQL in Kotlin - AndroidRepo
[Ktor + gradle plugin] 5.5.0 to 6.2.5 regression around Content-Length & Transfer-Encoding. Library Version 6.2.5.
Read more >
ExpediaGroup Graphql-Kotlin Issues - IssueHint
[Ktor + gradle plugin] 5.5.0 to 6.2.5 regression around Content-Length & Transfer-Encoding, open, 4, 2022-09-21, 2022-11-05.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found