Node.js boolean map keys may be communicated incorrectly
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Inizia riproducendo il problema con il proto e la richiesta Node.js forniti, oppure esegui l’immagine Docker fornita e ./ls_run.sh. Traccia il modo in cui Node.js serializza le chiavi booleane delle mappe negli oggetti JavaScript e confronta i casi con chiave false con la risposta Python. Il lavoro è completo quando le chiavi false rimangono false nel round trip da Node.js a Python, con un test di regressione se viene individuata una struttura di test esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem description
Hi all, we found an interesting bug. Given a map field which contained a key of type bool, when using a Node.js client to send the map field to a Python server, boolean keys in map fields are incorrectly deserialized in the response. Specifically, False keys are converted to True in the returned message.
Reproduction steps
The code snippet to help reproduce the issues is provided in Google drive.
You can reproduce the issue in either of the following two ways:
Option 1. Here is a simplified version of the code to reproduce the issue:
Proto file.
syntax = "proto3";
package map_hotpot;
option java_multiple_files = true;
option java_package = "org.grpctest.java.common.define";
option java_outer_classname = "MapProto";
message MapPot {
map<bool, double> bool_double_value = 1;
map<bool, int64> bool_int_value = 2;
map<bool, bool> bool_bool_value = 3;
map<bool, string> bool_string_value = 4;
}
service HotpotService {
// UNARY
rpc UnaryPot(MapPot) returns (MapPot);
}
Nodejs client request message:
const request = {
bool_double_value: { true: 3.14 },
bool_int_value: { false: 42 },
bool_bool_value: { true: true },
bool_string_value: { **false**: "hello" }
};
The response message as received by Python client
python server Received request: bool_double_value {
key: true
value: 3.14
}
bool_int_value {
key: true
value: 42
}
bool_bool_value {
key: true
value: true
}
bool_string_value {
key: true
value: "hello"
}
We can see that the second and fourth key are switched from "false" to "true", which is expected.
Option 2. For your convenience, we’ve provided the Docker image.
Load the Docker image: You can access it via this command ``docker pull lishuoiscas/grpc_app:0723
Prepare the code:
Create a folder named grpc-auto-test
Place the relevant code inside this folder
Run the Docker container:
Replace {your_path} with the absolute path to your local grpc-auto-test folder:
docker run -it --rm -v {your_path}/grpc-auto-test:/grpc-auto-test <image:tag>
Inside the container, reproduce the issue by running:
./ls_run.sh
Environment
- MacOs 15.3 and Windows 11
- Node version 22.17.1
-Python 3.13
Additional context
Plausible reason: We confirmed the problem originated from Node.js server by analysing the response sent from Node.js server, as captured by tcpdump. This issue stemmed from the way Node.js convert map values to Javascript objects, where map keys must be a string. We have not found sufficient gRPC-node documentation to determine the exact cause behind this issue. However, it is very likely that the issue was caused by how the string form of map keys, as stored in Javascript objects, was converted to boolean type during serialization. In Javascript, the string “false”, when converted to a boolean value, will be boolean true (refer to the debuggping_process_1.png). If our assumption is true, then one solution to patch this bug would be to introduce a simple condition during string to boolean conversion as shown in the debuggping_process_2.png.
Please note that the suggested change was not based on gRPC-node code, it simply suggested a general idea to fix this issue.
Can you help fix it or double check it? Thank you.
- Lingua principale
- TypeScript
- Stelle
- 4.8k
- Fork
- 721
- Merge medio
- 2g 22h
- PR unite (30g)
- 17
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
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 grpc/grpc-node
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 3 giorni
-
CompressionFilter’s IdentityHandler.writeMessage calls Buffer-only .copy() on caller-provided messageForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 3 giorni
-
package: @grpc/grpc-js
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
grpc/grpc-node#2993 · 3 commenti · 5 reazioni ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
grpc/grpc-node#3091 · 1 reazione ·
I maintainer di solito rispondono entro 3 giorni
-
feature request
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
grpc/grpc-node#3077 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di grpc/grpc-node
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
juice-shop/juice-shop#3706 ·
I maintainer di solito rispondono entro 1 giorno
-
sbx up from a subfolder silently pushes the whole work treeForse già presa @pdettori l’ha presa oggi. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
outline/outline#14348 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno