maybe I'm not seeing the forest for the trees anymore and if I do, I'm sorry, but I've been stuck on an issue now for a few hours. I updated a message in my proto file by adding a field (includeObsolete):
message GetAllDocumentsRequest {
RequestHeader header = 1;
bool include_obsolete= 2;
}
The respective code is built correctly as far as I can tell (at least I can access the field include_obsolete inside GetAllDocumentsRequest), but whenever I print the request in my grpc service, the field include_obsolete is set to false
.
async fn get_all_documents(
&self,
request: Request<GetAllDocumentsRequest>,
) -> Result<Response<GetDocumentsReply>, Status> {
println!("Request: {:?}", request); // here include_obsolete is always false
foo();
bar();
...
Here's the request I use in Postman:
{
"include_obsolete": true,
"header": {
"comment": {
"actionType": "action",
"comment": "elit sit esse",
"createdBy": "in dolore enim",
"createdDate": "3410",
"ID": 45
},
"messageType": "officia est",
"senderAddress": "aute sed irure anim labore",
"senderId": "mollit sunt",
"token": "dolore dolor",
"user": "erwin"
}
}
And for reference the output of println!:
Request: Request { metadata: MetadataMap { headers: {"grpc-accept-encoding": "identity,deflate,gzip", "accept-encoding": "identity", "user-agent": "grpc-node-js/1.8.10", "content-type": "application/grpc", "te": "trailers"} }, message: GetAllDocumentsRequest { header: Some(RequestHeader { sender_address: "aute sed irure anim labore", sender_id: "mollit sunt", user: "erwin", comment: Some(Comment { id: 45, created_date: 3410, created_by: "in dolore enim", action_type: "action", comment: "elit sit esse" }), message_type: Some("officia est"), token: Some("dolore dolor") }), include_obsolete: false }, extensions: Extensions }
All other fields are printed correctly whenever I change the values in the request. I also tried running cargo clean already, but without success.
The problem was actually with Postman, because for whatever reason it did not send the updated version of the JSON request and just skipped the newly added field. After re-importing the API it worked.