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

Import in service class is broken for nested request and response messages #201

Open
2 tasks done
antonkomarev opened this issue Jan 6, 2025 · 2 comments · May be fixed by #203
Open
2 tasks done

Import in service class is broken for nested request and response messages #201

antonkomarev opened this issue Jan 6, 2025 · 2 comments · May be fixed by #203

Comments

@antonkomarev
Copy link

antonkomarev commented Jan 6, 2025

Preflight Checklist

  • I have searched the issue tracker for an issue that matches the one I want to file, without success.
  • I am not looking for support or already pursued the available support channels without success.

Version

0.12.0

PHP version

8.2

Go version

No response

Expected Behavior

interface EmployeeService
{
    public function ListEmployee(
        array $ctx,
        \Org\Example\ListEmployee\Request $req
    ): \Org\Example\ListEmployee\Response;
}

Actual Behavior

Messages are generated correctly by protoc, but service interface has broken imports if Request and Response messages are nested.

interface EmployeeService
{
    public function ListEmployee(
        array $ctx,
        \Org\Example\Request $req
    ): \Org\Example\Response;
}

Steps To Reproduce

syntax = "proto3";

package org.example;

service EmployeeService {
  rpc ListEmployee(ListEmployee.Request) returns (ListEmployee.Response);
}

message ListEmployee {
  message Request {
    string organization_id = 1;
  }

  message Response {
    oneof response {
      Result result = 1;
      string access_denied = 2;
    }

    message Result {
      repeated Employee employees = 1;
    }

    message Employee {
      string id = 1;
      string name = 2;
    }
  }
}

Generate code with:

./bin/proto/${ARCH}/protoc \
    --plugin=protoc-gen-twirp_php=./bin/proto/${ARCH}/protoc-gen-twirp_php \
    -I=./proto \
    -I=./proto/include \
    --twirp_php_out=./generated \
    --php_out=./generated \
    $(find ./proto -name "*.proto" -not -path "./proto/include/*")

Additional Information

No response

@sagikazarmark
Copy link
Member

Thanks for reporting!

I rarely use nested messages TBH.

Are you interested in contributing a failing test case and a patch?

@antonkomarev antonkomarev linked a pull request Jan 6, 2025 that will close this issue
@antonkomarev
Copy link
Author

@sagikazarmark I just found a spec with nested request & response and it's working well in TypeScript Twirp generator, but not working for PHP.

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

Successfully merging a pull request may close this issue.

2 participants