On SQLException, invalid Content-Length header in response
See original GitHub issueDescribe the bug
Hi,
this is a follow up issue from https://github.com/keycloak/keycloak/issues/10176 / https://github.com/keycloak/keycloak/pull/10206.
I rebuild a Quarkus based distribution docker container from main (febb447919044943241ad97200821c7da5099cb3) and integration the container into my test suite.
While running the test suite, I noticed tests that failing on 17.0.0, now just hangs.
Version
18.0.0-SNAPSHOT (febb447919044943241ad97200821c7da5099cb3)
Expected behavior
Even If I send garbage to Keycloak, I would except a valid HTTP response including connection termination.
Actual behavior
If a SQLException occurred on PUT, the http response contains forcefully content-length: 0
while the body cloud be non-zero.
curl trace
== Info: Trying 127.0.0.1:8080...
== Info: Connected to localhost (127.0.0.1) port 8080 (#0)
=> Send header, 1205 bytes (0x4b5)
0000: 50 55 54 20 2f 61 64 6d 69 6e 2f 72 65 61 6c 6d PUT /admin/realm
0010: 73 2f 6d 61 73 74 65 72 2f 61 75 74 68 65 6e 74 s/master/authent
0020: 69 63 61 74 69 6f 6e 2f 66 6c 6f 77 73 2f 64 32 ication/flows/d2
0030: 64 66 37 66 35 64 2d 66 32 33 35 2d 34 39 61 36 df7f5d-f235-49a6
0040: 2d 38 34 30 32 2d 63 36 33 61 62 31 32 35 38 30 -8402-c63ab12580
0050: 30 33 20 48 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 03 HTTP/1.1..Hos
0060: 74 3a 20 6c 6f 63 61 6c 68 6f 73 74 3a 38 30 38 t: localhost:808
0070: 30 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a 20 63 0..User-Agent: c
0080: 75 72 6c 2f 37 2e 37 37 2e 30 0d 0a 41 63 63 65 url/7.77.0..Acce
0090: 70 74 3a 20 2a 2f 2a 0d 0a 41 75 74 68 6f 72 69 pt: */*..Authori
00a0: 7a 61 74 69 6f 6e 3a 20 42 65 61 72 65 72 20 65 zation: Bearer e
00b0: 79 4a 68 62 47 63 69 4f 69 4a 53 55 7a 49 31 4e yJhbGciOiJSUzI1N
00c0: 69 49 73 49 6e 52 35 63 43 49 67 4f 69 41 69 53 iIsInR5cCIgOiAiS
00d0: 6c 64 55 49 69 77 69 61 32 6c 6b 49 69 41 36 49 ldUIiwia2lkIiA6I
00e0: 43 4a 6d 56 6b 4d 74 53 47 45 32 4d 6d 74 42 52 CJmVkMtSGE2MmtBR
00f0: 33 42 66 4e 47 38 34 4c 55 4e 6d 61 6c 6c 59 54 3BfNG84LUNmallYT
0100: 45 6c 36 4f 47 56 59 53 58 64 6b 59 6d 56 61 4d El6OGVYSXdkYmVaM
0110: 6d 6c 4a 51 6e 5a 69 58 31 68 4e 49 6e 30 2e 65 mlJQnZiX1hNIn0.e
0120: 79 4a 6c 65 48 41 69 4f 6a 45 32 4e 44 55 7a 4e yJleHAiOjE2NDUzN
0130: 54 6b 77 4f 54 55 73 49 6d 6c 68 64 43 49 36 4d TkwOTUsImlhdCI6M
0140: 54 59 30 4e 54 4d 31 4f 54 41 7a 4e 53 77 69 61 TY0NTM1OTAzNSwia
0150: 6e 52 70 49 6a 6f 69 4e 57 51 77 4e 6a 45 79 4e nRpIjoiNWQwNjEyN
0160: 57 4d 74 4e 32 52 6a 5a 53 30 30 4f 44 41 35 4c WMtN2RjZS00ODA5L
0170: 54 68 6b 4e 54 49 74 4e 44 6b 35 5a 6a 4d 34 4e ThkNTItNDk5ZjM4N
0180: 47 51 30 59 6d 4d 31 49 69 77 69 61 58 4e 7a 49 GQ0YmM1IiwiaXNzI
0190: 6a 6f 69 61 48 52 30 63 44 6f 76 4c 32 78 76 59 joiaHR0cDovL2xvY
01a0: 32 46 73 61 47 39 7a 64 44 6f 34 4d 44 67 77 4c 2FsaG9zdDo4MDgwL
01b0: 33 4a 6c 59 57 78 74 63 79 39 74 59 58 4e 30 5a 3JlYWxtcy9tYXN0Z
01c0: 58 49 69 4c 43 4a 7a 64 57 49 69 4f 69 49 78 4e XIiLCJzdWIiOiIxN
01d0: 44 52 6d 4f 44 42 69 5a 43 30 78 5a 57 4d 7a 4c DRmODBiZC0xZWMzL
01e0: 54 51 77 4e 54 49 74 59 54 42 68 59 69 31 6c 4f TQwNTItYTBhYi1lO
01f0: 47 4a 6a 4f 44 45 35 4d 44 45 31 4e 32 55 69 4c GJjODE5MDE1N2UiL
0200: 43 4a 30 65 58 41 69 4f 69 4a 43 5a 57 46 79 5a CJ0eXAiOiJCZWFyZ
0210: 58 49 69 4c 43 4a 68 65 6e 41 69 4f 69 4a 68 5a XIiLCJhenAiOiJhZ
0220: 47 31 70 62 69 31 6a 62 47 6b 69 4c 43 4a 7a 5a G1pbi1jbGkiLCJzZ
0230: 58 4e 7a 61 57 39 75 58 33 4e 30 59 58 52 6c 49 XNzaW9uX3N0YXRlI
0240: 6a 6f 69 4d 6d 4a 6b 4d 7a 51 7a 5a 54 49 74 4f joiMmJkMzQzZTItO
0250: 54 4d 32 5a 53 30 30 5a 6d 59 77 4c 54 6b 77 4e TM2ZS00ZmYwLTkwN
0260: 47 51 74 5a 6d 4e 69 4d 47 51 35 5a 57 49 34 5a GQtZmNiMGQ5ZWI4Z
0270: 44 59 79 49 69 77 69 59 57 4e 79 49 6a 6f 69 4d DYyIiwiYWNyIjoiM
0280: 53 49 73 49 6e 4e 6a 62 33 42 6c 49 6a 6f 69 63 SIsInNjb3BlIjoic
0290: 48 4a 76 5a 6d 6c 73 5a 53 42 6c 62 57 46 70 62 HJvZmlsZSBlbWFpb
02a0: 43 49 73 49 6e 4e 70 5a 43 49 36 49 6a 4a 69 5a CIsInNpZCI6IjJiZ
02b0: 44 4d 30 4d 32 55 79 4c 54 6b 7a 4e 6d 55 74 4e DM0M2UyLTkzNmUtN
02c0: 47 5a 6d 4d 43 30 35 4d 44 52 6b 4c 57 5a 6a 59 GZmMC05MDRkLWZjY
02d0: 6a 42 6b 4f 57 56 69 4f 47 51 32 4d 69 49 73 49 jBkOWViOGQ2MiIsI
02e0: 6d 56 74 59 57 6c 73 58 33 5a 6c 63 6d 6c 6d 61 mVtYWlsX3Zlcmlma
02f0: 57 56 6b 49 6a 70 6d 59 57 78 7a 5a 53 77 69 63 WVkIjpmYWxzZSwic
0300: 48 4a 6c 5a 6d 56 79 63 6d 56 6b 58 33 56 7a 5a HJlZmVycmVkX3VzZ
0310: 58 4a 75 59 57 31 6c 49 6a 6f 69 59 57 52 74 61 XJuYW1lIjoiYWRta
0320: 57 34 69 66 51 2e 65 48 51 68 4a 37 58 39 61 33 W4ifQ.eHQhJ7X9a3
0330: 30 74 51 79 5a 6b 44 74 4b 63 77 2d 41 34 76 75 0tQyZkDtKcw-A4vu
0340: 50 57 35 4e 68 6b 43 64 6f 32 4a 39 47 36 62 64 PW5NhkCdo2J9G6bd
0350: 34 39 55 48 65 5f 42 47 6a 34 4d 35 47 36 41 46 49UHe_BGj4M5G6AF
0360: 6c 64 2d 6f 50 56 64 37 56 36 47 36 78 41 52 44 ld-oPVd7V6G6xARD
0370: 38 6a 31 67 67 6a 48 61 33 49 79 62 35 4f 57 61 8j1ggjHa3Iyb5OWa
0380: 4e 36 6d 48 43 68 62 38 77 48 49 43 6d 49 75 53 N6mHChb8wHICmIuS
0390: 77 4d 2d 51 6b 63 65 49 6c 35 68 45 54 75 2d 55 wM-QkceIl5hETu-U
03a0: 30 76 31 5a 39 77 54 6e 55 34 53 38 50 77 46 79 0v1Z9wTnU4S8PwFy
03b0: 51 53 6a 6a 35 70 69 67 58 33 52 67 7a 50 7a 37 QSjj5pigX3RgzPz7
03c0: 45 39 44 7a 48 45 41 70 72 6a 65 56 4e 52 68 30 E9DzHEAprjeVNRh0
03d0: 46 32 75 33 79 6b 59 43 4e 5a 64 2d 46 35 34 68 F2u3ykYCNZd-F54h
03e0: 6c 6a 75 5f 39 6f 45 50 55 4a 58 57 7a 37 79 54 lju_9oEPUJXWz7yT
03f0: 6a 73 57 4d 6b 4f 46 4c 46 32 6a 34 77 73 7a 33 jsWMkOFLF2j4wsz3
0400: 49 69 66 31 4b 78 42 37 62 78 44 41 35 43 59 77 Iif1KxB7bxDA5CYw
0410: 64 63 6a 7a 73 4e 66 65 4a 35 77 66 5a 4e 59 47 dcjzsNfeJ5wfZNYG
0420: 4f 6b 48 6a 33 34 63 67 45 58 4a 6e 51 47 4d 6a OkHj34cgEXJnQGMj
0430: 64 50 74 54 6f 36 47 6b 5f 4b 64 51 74 4b 43 6c dPtTo6Gk_KdQtKCl
0440: 68 7a 74 39 52 36 77 67 4d 4a 45 72 74 68 36 71 hzt9R6wgMJErth6q
0450: 77 37 63 42 6e 7a 6a 50 34 39 36 37 48 67 5a 50 w7cBnzjP4967HgZP
0460: 63 57 59 4c 47 37 37 79 30 6a 6e 47 5f 69 68 4b cWYLG77y0jnG_ihK
0470: 59 56 44 65 55 39 55 4d 5f 6c 59 51 0d 0a 43 6f YVDeU9UM_lYQ..Co
0480: 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70 70 6c ntent-Type: appl
0490: 69 63 61 74 69 6f 6e 2f 6a 73 6f 6e 0d 0a 43 6f ication/json..Co
04a0: 6e 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 36 33 ntent-Length: 63
04b0: 30 0d 0a 0d 0a 0....
=> Send data, 630 bytes (0x276)
0000: 7b 22 69 64 22 3a 22 64 32 64 66 37 66 35 64 2d {"id":"d2df7f5d-
0010: 66 32 33 35 2d 34 39 61 36 2d 38 34 30 32 2d 63 f235-49a6-8402-c
0020: 36 33 61 62 31 32 35 38 30 30 33 22 2c 22 61 6c 63ab1258003","al
0030: 69 61 73 22 3a 22 73 61 6d 6c 20 65 63 70 22 2c ias":"saml ecp",
0040: 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 41 "description":"A
0050: 68 78 37 76 6f 6f 68 65 69 6a 6f 6f 37 5a 6f 68 hx7vooheijoo7Zoh
0060: 34 61 65 58 65 65 31 61 65 6d 32 61 65 68 6f 68 4aeXee1aem2aehoh
0070: 39 73 65 69 67 68 65 4b 32 79 65 63 6f 6e 67 33 9seigheK2yecong3
0080: 63 69 65 67 6f 6f 74 31 63 65 65 31 65 69 64 6f ciegoot1cee1eido
0090: 67 68 35 6b 6f 6f 78 65 65 37 6e 6f 68 31 69 6f gh5kooxee7noh1io
00a0: 68 6f 68 33 61 69 64 35 41 69 66 38 69 6f 64 6f hoh3aid5Aif8iodo
00b0: 6f 32 61 4c 75 6a 65 69 6a 61 69 6d 36 58 61 68 o2aLujeijaim6Xah
00c0: 72 61 69 33 49 65 72 61 68 6e 67 65 6d 61 69 70 rai3Ierahngemaip
00d0: 65 69 53 68 6f 35 69 69 34 75 67 68 32 61 65 63 eiSho5ii4ugh2aec
00e0: 61 65 76 65 37 61 69 53 69 36 61 69 7a 35 65 65 aeve7aiSi6aiz5ee
00f0: 73 6f 35 74 68 61 66 6f 6f 79 75 4e 33 6f 6f 6b so5thafooyuN3ook
0100: 37 41 69 6a 37 69 65 77 65 65 71 75 65 69 4d 39 7Aij7ieweequeiM9
0110: 4e 65 65 6d 61 65 50 68 75 71 75 61 68 69 65 63 NeemaePhuquahiec
0120: 68 39 53 61 77 61 65 42 75 35 61 6b 65 65 63 68 h9SawaeBu5akeech
0130: 6f 6f 34 66 61 69 70 68 6f 39 61 68 74 61 68 63 oo4faipho9ahtahc
0140: 68 65 65 4b 31 62 75 31 6f 6f 46 6f 6f 38 72 22 heeK1bu1ooFoo8r"
0150: 2c 22 70 72 6f 76 69 64 65 72 49 64 22 3a 22 62 ,"providerId":"b
0160: 61 73 69 63 2d 66 6c 6f 77 22 2c 22 74 6f 70 4c asic-flow","topL
0170: 65 76 65 6c 22 3a 74 72 75 65 2c 22 62 75 69 6c evel":true,"buil
0180: 74 49 6e 22 3a 74 72 75 65 2c 22 61 75 74 68 65 tIn":true,"authe
0190: 6e 74 69 63 61 74 69 6f 6e 45 78 65 63 75 74 69 nticationExecuti
01a0: 6f 6e 73 22 3a 5b 7b 22 61 75 74 68 65 6e 74 69 ons":[{"authenti
01b0: 63 61 74 6f 72 43 6f 6e 66 69 67 22 3a 6e 75 6c catorConfig":nul
01c0: 6c 2c 22 61 75 74 68 65 6e 74 69 63 61 74 6f 72 l,"authenticator
01d0: 22 3a 22 68 74 74 70 2d 62 61 73 69 63 2d 61 75 ":"http-basic-au
01e0: 74 68 65 6e 74 69 63 61 74 6f 72 22 2c 22 61 75 thenticator","au
01f0: 74 68 65 6e 74 69 63 61 74 6f 72 46 6c 6f 77 22 thenticatorFlow"
0200: 3a 66 61 6c 73 65 2c 22 72 65 71 75 69 72 65 6d :false,"requirem
0210: 65 6e 74 22 3a 22 43 4f 4e 44 49 54 49 4f 4e 41 ent":"CONDITIONA
0220: 4c 22 2c 22 70 72 69 6f 72 69 74 79 22 3a 31 30 L","priority":10
0230: 2c 22 61 75 74 68 65 74 69 63 61 74 6f 72 46 6c ,"autheticatorFl
0240: 6f 77 22 3a 66 61 6c 73 65 2c 22 66 6c 6f 77 41 ow":false,"flowA
0250: 6c 69 61 73 22 3a 6e 75 6c 6c 2c 22 75 73 65 72 lias":null,"user
0260: 53 65 74 75 70 41 6c 6c 6f 77 65 64 22 3a 66 61 SetupAllowed":fa
0270: 6c 73 65 7d 5d 7d lse}]}
== Info: Mark bundle as not supporting multiuse
<= Recv header, 36 bytes (0x24)
0000: 48 54 54 50 2f 31 2e 31 20 35 30 30 20 49 6e 74 HTTP/1.1 500 Int
0010: 65 72 6e 61 6c 20 53 65 72 76 65 72 20 45 72 72 ernal Server Err
0020: 6f 72 0d 0a or..
<= Recv header, 26 bytes (0x1a)
0000: 63 6f 6e 74 65 6e 74 2d 74 79 70 65 3a 20 74 65 content-type: te
0010: 78 74 2f 70 6c 61 69 6e 0d 0a xt/plain..
<= Recv header, 19 bytes (0x13)
0000: 63 6f 6e 74 65 6e 74 2d 6c 65 6e 67 74 68 3a 20 content-length:
0010: 30 0d 0a 0..
== Info: no chunk, no close, no size. Assume close to signal end
<= Recv header, 2 bytes (0x2)
0000: 0d 0a ..
<= Recv data, 586 bytes (0x24a)
0000: 7b 22 69 64 22 3a 22 64 32 64 66 37 66 35 64 2d {"id":"d2df7f5d-
0010: 66 32 33 35 2d 34 39 61 36 2d 38 34 30 32 2d 63 f235-49a6-8402-c
0020: 36 33 61 62 31 32 35 38 30 30 33 22 2c 22 61 6c 63ab1258003","al
0030: 69 61 73 22 3a 22 73 61 6d 6c 20 65 63 70 22 2c ias":"saml ecp",
0040: 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 41 "description":"A
0050: 68 78 37 76 6f 6f 68 65 69 6a 6f 6f 37 5a 6f 68 hx7vooheijoo7Zoh
0060: 34 61 65 58 65 65 31 61 65 6d 32 61 65 68 6f 68 4aeXee1aem2aehoh
0070: 39 73 65 69 67 68 65 4b 32 79 65 63 6f 6e 67 33 9seigheK2yecong3
0080: 63 69 65 67 6f 6f 74 31 63 65 65 31 65 69 64 6f ciegoot1cee1eido
0090: 67 68 35 6b 6f 6f 78 65 65 37 6e 6f 68 31 69 6f gh5kooxee7noh1io
00a0: 68 6f 68 33 61 69 64 35 41 69 66 38 69 6f 64 6f hoh3aid5Aif8iodo
00b0: 6f 32 61 4c 75 6a 65 69 6a 61 69 6d 36 58 61 68 o2aLujeijaim6Xah
00c0: 72 61 69 33 49 65 72 61 68 6e 67 65 6d 61 69 70 rai3Ierahngemaip
00d0: 65 69 53 68 6f 35 69 69 34 75 67 68 32 61 65 63 eiSho5ii4ugh2aec
00e0: 61 65 76 65 37 61 69 53 69 36 61 69 7a 35 65 65 aeve7aiSi6aiz5ee
00f0: 73 6f 35 74 68 61 66 6f 6f 79 75 4e 33 6f 6f 6b so5thafooyuN3ook
0100: 37 41 69 6a 37 69 65 77 65 65 71 75 65 69 4d 39 7Aij7ieweequeiM9
0110: 4e 65 65 6d 61 65 50 68 75 71 75 61 68 69 65 63 NeemaePhuquahiec
0120: 68 39 53 61 77 61 65 42 75 35 61 6b 65 65 63 68 h9SawaeBu5akeech
0130: 6f 6f 34 66 61 69 70 68 6f 39 61 68 74 61 68 63 oo4faipho9ahtahc
0140: 68 65 65 4b 31 62 75 31 6f 6f 46 6f 6f 38 72 22 heeK1bu1ooFoo8r"
0150: 2c 22 70 72 6f 76 69 64 65 72 49 64 22 3a 22 62 ,"providerId":"b
0160: 61 73 69 63 2d 66 6c 6f 77 22 2c 22 74 6f 70 4c asic-flow","topL
0170: 65 76 65 6c 22 3a 74 72 75 65 2c 22 62 75 69 6c evel":true,"buil
0180: 74 49 6e 22 3a 74 72 75 65 2c 22 61 75 74 68 65 tIn":true,"authe
0190: 6e 74 69 63 61 74 69 6f 6e 45 78 65 63 75 74 69 nticationExecuti
01a0: 6f 6e 73 22 3a 5b 7b 22 61 75 74 68 65 6e 74 69 ons":[{"authenti
01b0: 63 61 74 6f 72 22 3a 22 68 74 74 70 2d 62 61 73 cator":"http-bas
01c0: 69 63 2d 61 75 74 68 65 6e 74 69 63 61 74 6f 72 ic-authenticator
01d0: 22 2c 22 61 75 74 68 65 6e 74 69 63 61 74 6f 72 ","authenticator
01e0: 46 6c 6f 77 22 3a 66 61 6c 73 65 2c 22 72 65 71 Flow":false,"req
01f0: 75 69 72 65 6d 65 6e 74 22 3a 22 43 4f 4e 44 49 uirement":"CONDI
0200: 54 49 4f 4e 41 4c 22 2c 22 70 72 69 6f 72 69 74 TIONAL","priorit
0210: 79 22 3a 31 30 2c 22 61 75 74 68 65 74 69 63 61 y":10,"authetica
0220: 74 6f 72 46 6c 6f 77 22 3a 66 61 6c 73 65 2c 22 torFlow":false,"
0230: 75 73 65 72 53 65 74 75 70 41 6c 6c 6f 77 65 64 userSetupAllowed
0240: 22 3a 66 61 6c 73 65 7d 5d 7d ":false}]}
How to Reproduce?
I wrote a shell script is simply reproduce and display the error:
#!/usr/bin/env sh
TOKEN=$(curl -s -d 'client_id=admin-cli' -d 'username=admin' -d 'password=admin123' -d 'grant_type=password' 'http://localhost:8080/realms/master/protocol/openid-connect/token' | jq -r '.access_token')
FLOW_ID=$(curl -s -XPOST -H "Authorization: Bearer ${TOKEN}" 'http://localhost:8080/admin/realms/master/partial-export?exportGroupsAndRoles=false&exportClients=false' | jq -r '.authenticationFlows[] | select(.alias == "saml ecp") | .id')
curl -XPUT "http://localhost:8080/admin/realms/master/authentication/flows/${FLOW_ID}" \
--ignore-content-length \
--trace /dev/stderr \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"id":"'"${FLOW_ID}"'","alias":"saml ecp","description":"Ahx7vooheijoo7Zoh4aeXee1aem2aehoh9seigheK2yecong3ciegoot1cee1eidogh5kooxee7noh1iohoh3aid5Aif8iodoo2aLujeijaim6Xahrai3IerahngemaipeiSho5ii4ugh2aecaeve7aiSi6aiz5eeso5thafooyuN3ook7Aij7ieweequeiM9NeemaePhuquahiech9SawaeBu5akeechoo4faipho9ahtahcheeK1bu1ooFoo8r","providerId":"basic-flow","topLevel":true,"builtIn":true,"authenticationExecutions":[{"authenticatorConfig":null,"authenticator":"http-basic-authenticator","authenticatorFlow":false,"requirement":"CONDITIONAL","priority":10,"autheticatorFlow":false,"flowAlias":null,"userSetupAllowed":false}]}'
By default, curl would stop processing after 0 bytes of reading the body and mention that there is additional content.
* Excess found: excess = 586 url = /admin/realms/master/authentication/flows/d2df7f5d-f235-49a6-8402-c63ab1258003 (zero-length body)
Thats the reason, why I add --ignore-content-length
to see the additional output. Then curl starts to just hangs like the Apache HttpClient in my test suite.
Anything else?
If curl/Apache http client is waiting, I was thinking about that Keycloak is not going to terminate the server connection.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
@jkroepke Thanks. I was able to reproduce using cURL and I’m trying to see how to proceed now.
Thats fine for me.
Yes, I will do it later.