Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3413

Thrift code generation bug in Go when extending service

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.10.0
    • None
    • None

    Description

      Given the following 2 thrift simple thrift files

      base.thrift
      namespace go base
      
      /** Common context for a request containing information about the requester. */
      struct RequestContext {
          /** ID */
          1:required i64 ID
      }
      
      exception WError {
          /** Identifying code for the error */
          1:i64 code,
      
          /** Descriptive error message */
          2:string message,
      }
      
      service BaseService {
          /** A simple ping to see if the service is alive */
          void ping() throws (1:WError err)
      }
      
      extended.thrift
      namespace go extended
      
      include "base.thrift"
      
      struct Extended {
          1:required i64 ID
      }
      
      service ExtendedService extends base.BaseService{
          /**
          Creates the requested Translation. Returns the representation of the
          created Translation with a generated ID and the userId attached.
          */
          Extended createExtended(1:base.RequestContext rc, 2:Extended ex) throws (1:base.WError err)
      }
      
      

      This is a very simple service extending another service. When using thrift (0.9.3, 1.0.0-dev both tested), there is an generation problem that requires fixing by hand.

      Running this for generation

      thrift -r -gen go:package_prefix=github.com/myrepo/gen-go/ extended.thrift
      

      if I then change directories and run a go build, I get the following error.

      $> cd gen-go/extended/extended_service-remote
      $> go build
      # github.com/myrepo/gen-go/extended/extended_service-remote
      ./extended_service-remote.go:134: undefined: extended.NewRequestContext
      

      This is easily reproducible with these steps.

      Attachments

        1. THRIFT-3413-Thrift-code-generation-bug-in-Go-when-ex.patch
          3 kB
          Jens Geyer
        2. THRIFT-3413-Thrift-code-generation-bug-in-Go-when-ex.patch
          7 kB
          Jens Geyer
        3. extended.thrift
          0.5 kB
          Jens Geyer
        4. base.thrift
          0.5 kB
          Jens Geyer

        Issue Links

          Activity

            People

              jensg Jens Geyer
              ryanseltzer Ryan Seltzer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: