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

Prepend '::' to Twirp::Service and Twirp::Client to prevent namespace collisions #77

Merged
merged 1 commit into from
Mar 21, 2022
Merged

Prepend '::' to Twirp::Service and Twirp::Client to prevent namespace collisions #77

merged 1 commit into from
Mar 21, 2022

Conversation

etipton
Copy link

@etipton etipton commented Mar 1, 2022

I ran into this issue when I structured my protobufs in such a way that the resulting ruby file ended up like...

module CompanyName
  module Twirp
    class MyNewService < Twirp::Service
[...]

which causes:

uninitialized constant CompanyName::Twirp::Service (NameError)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@etipton
Copy link
Author

etipton commented Mar 1, 2022

workaround, for anyone who stumbles on this:

module CompanyName
  module Twirp
    Service = ::Twirp::Service
    Client  = ::Twirp::Client
  end
end

@wmatveyenko
Copy link
Collaborator

Hi. Thanks for your contribution. Can you add some tests that catch this error? Also, please add a comment with "By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license."

@etipton
Copy link
Author

etipton commented Mar 8, 2022

Hi. Thanks for your contribution. Can you add some tests that catch this error? Also, please add a comment with "By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license."

Updated the PR description w/ that comment.

Hmm, would that be a go test since it's testing the code-generation? (TBH my golang-fu is not very strong 😬)

But -- this change is so simple that as long as existing tests still pass, it should be acceptable IMO. Here is all that prefixing with :: means, if unfamiliar: https://stackoverflow.com/a/10064341/1938879 -- but if you still feel a spec is necessary, could you help write one / refer someone to help?

@etipton
Copy link
Author

etipton commented Mar 8, 2022

(Also thx for taking a look!)

@wmatveyenko wmatveyenko merged commit 0ec627f into arthurnn:main Mar 21, 2022
@wmatveyenko
Copy link
Collaborator

Thanks for the explanation.

@etipton etipton deleted the fix-namespacing branch March 22, 2022 17:11
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 this pull request may close these issues.

2 participants