`HttpClient.send` puts a header's string where `Response` says `Array String`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 86/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Inizia in Gren/Kernel/HttpClient.js, in _HttpClient_formatResponse, e confrontalo con _HttpClient_formatResponseLegacy. Esegui la riproduzione collegata con gren make Main --output=app && node app, quindi verifica che i valori degli header della risposta siano array, che i valori ripetuti di set-cookie vengano preservati e che l’output esistente termini senza il fallimento della catena di promise.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Found against: gren 0.6.6, gren-lang/core 7.4.2, gren-lang/node 6.1.3, node 22
Reproduction: https://github.com/gilramir/gren-bug-reports/tree/main/2026-09-15-httpclient-header-values
HttpClient.Response's headers are a Dict String (Array String), but
HttpClient.send stores each header's value as a plain string. So for
content-type: text/plain, Array.length of the values is 10 and
Array.first is Just "t", and String.join ", " values throws inside
fetch's promise chain after the task has already succeeded: the program
silently stops, with nothing on stderr and exit status 0. A repeated
set-cookie also keeps only the last cookie.
Reproduction
gren.json dependencies: gren-lang/core 7.4.2, gren-lang/node 6.1.3. Save as src/Main.gren. Build and run with gren make Main --output=app && node app; the third row is never printed:
module Main exposing (main)
import Dict
import HttpClient
import Init
import Node
import Stream
import Task
main : Node.SimpleProgram a
main =
Node.defineSimpleProgram <| \env ->
Init.await HttpClient.initialize <| \http ->
let
print line =
Stream.writeLineAsBytes line env.stdout
|> Task.onError (\_ -> Task.succeed env.stdout)
in
Node.endSimpleProgram
(HttpClient.get "data:text/plain,x"
|> HttpClient.send http
|> Task.andThen
(\response ->
let
values =
Dict.get "content-type" response.headers |> Maybe.withDefault []
in
print "| call | result | expected |\n|---|---|---|"
|> Task.andThen (\_ -> print ("| `Array.length values` | " ++ String.fromInt (Array.length values) ++ " | 1 |"))
|> Task.andThen (\_ -> print ("| `Array.first values` | " ++ Debug.toString (Array.first values) ++ " | Just \"text/plain\" |"))
|> Task.andThen (\_ -> print ("| `String.join \", \" values` | " ++ String.join ", " values ++ " | text/plain |"))
)
|> Task.onError (\_ -> print "request failed")
)
Output:
$ node app; echo "exit status $?"
| call | result | expected |
|---|---|---|
| `Array.length values` | 10 | 1 |
| `Array.first values` | Just "t" | Just "text/plain" |
exit status 0
Cause
_HttpClient_formatResponse in Gren/Kernel/HttpClient.js, which send uses:
for (const [key, value] of res.headers.entries()) {
headerDict = A3(__Dict_set, key.toLowerCase(), value, headerDict);
}
Headers.entries() gives each value as a string. fetch already joins a
repeated header with ", ", except set-cookie, which entries() gives once
per cookie, so __Dict_set keeps only the last one. The streaming API's
_HttpClient_formatResponseLegacy reads res.headersDistinct, whose values are
arrays, and is not affected.
- Lingua principale
- JavaScript
- Stelle
- 13
- Fork
- 6
- Merge medio
- 4g 12h
- PR unite (30g)
- 3
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di gren-lang/node
-
`FileSystem.makeTempDirectory` crashes the program when it fails, instead of failing the taskAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
`ChildProcess.spawn` with `NoShell` looks for a program named after the program and its argumentsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
Tutte le issue di gren-lang/node
Issue simili
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
vercel/ai#21528 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
status: waiting triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
freeCodeCamp/freeCodeCamp#70412 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
rohitg00/ai-engineering-from-scratch#490 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 6 giorni