Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No found message or enum for google.protobuf.Duration or google.protobuf.Timestamp #12

Open
cayden-uw opened this issue Oct 25, 2021 · 3 comments

Comments

@cayden-uw
Copy link

When running npx @whisklabs/grpc on my proto file I get errors for every duration and timestamp field like the error below

No found message or enum: uwGrpc_google_protobuf_Duration [in "uwGrpc_IntValueDuration" field "duration = 2"]

I compared my proto to the one in your tests which uses timestamps and couldn't find any differences in imports or the one the fields are defined.

I am using Ubuntu 21.10, I have protoc installed and can successfully generate js libaries using protoc grpc-web

@askuzminov
Copy link
Contributor

askuzminov commented Dec 28, 2021

@cayden-uw Can you show an example of a proto file?

Did you add this file to the project? google/protobuf/duration.proto
and google/protobuf/timestamp.proto

protoc grpc-web automatically add package google.protobuf from here: https://github.com/protocolbuffers/protobuf/tree/master/src/google/protobuf

Our library generates clean code to control what needs to be turned on. Perhaps there is a need to add package google.protobuf by default too.

@stephennancekivell
Copy link

Hi, I've made a minimal reproduction that shows the issue.

syntax = "proto3";

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

message Sample {
  string value_a = 1;
  google.protobuf.Timestamp value_b = 2;
  google.protobuf.Duration value_c = 3;
}

When I run it

PROTO_DIR=mini/ PROTO_OUT=whisk npx @whisklabs/grpc
No found message or enum: google_protobuf_Timestamp [in "Sample" field "value_b = 2"]
No found message or enum: google_protobuf_Duration [in "Sample" field "value_c = 3"]

If I comment out value_b & value_c it runs.

Is there some other way to import packages or something?

PS, thanks for the lib 😊

@stephennancekivell
Copy link

Found a workaround.

From the same sample message definition.

First download the Timestamp and Duration definitions and put them in the same folder.

curl https://raw.githubusercontent.com/protocolbuffers/protobuf/master/src/google/protobuf/duration.proto -o mini/duration.proto
curl https://raw.githubusercontent.com/protocolbuffers/protobuf/master/src/google/protobuf/timestamp.proto -o mini/timestamp.proto

Then run it.

PROTO_DIR=mini/ PROTO_OUT=whisk npx @whisklabs/grpc

This gives output with an index.js like.

// Code created by generator @whisklabs/grpc
// https://github.com/whisklabs/grpc-ts
// Version: 1.1.1
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.google_protobuf_Timestamp = exports.Sample = exports.google_protobuf_Duration = void 0;
function google_protobuf_Duration() {
    return [
        [1, "seconds", "int64", 1],
        [2, "nanos", "int32", 1],
    ];
}
exports.google_protobuf_Duration = google_protobuf_Duration;
function Sample() {
    return [
        [1, "valueA", "string", 1],
        [2, "valueB", google_protobuf_Timestamp, 0],
        [3, "valueC", google_protobuf_Duration, 0],
    ];
}
exports.Sample = Sample;
function google_protobuf_Timestamp() {
    return [
        [1, "seconds", "int64", 1],
        [2, "nanos", "int32", 1],
    ];
}
exports.google_protobuf_Timestamp = google_protobuf_Timestamp;

Ideally, the library would know how to resolve these dependencies like the other proto generators.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants