Twirp

Latest version: v0.0.7

Safety actively analyzes 682361 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 7

8.1.2

What's Changed
* Add timostamm/protobuf-ts to implementations by QuantumGhost in https://github.com/twitchtv/twirp/pull/344
* Make README third-party table consistent by nihaals in https://github.com/twitchtv/twirp/pull/345
* Docs to migrate REST APIs to Twirp by marioizquierdo in https://github.com/twitchtv/twirp/pull/347
* Fix generation of the best practices page by hugosrc in https://github.com/twitchtv/twirp/pull/349
* Fix generated file name error in some cases by albenik in https://github.com/twitchtv/twirp/pull/351

New Contributors
* QuantumGhost made their first contribution in https://github.com/twitchtv/twirp/pull/344
* nihaals made their first contribution in https://github.com/twitchtv/twirp/pull/345
* hugosrc made their first contribution in https://github.com/twitchtv/twirp/pull/349
* albenik made their first contribution in https://github.com/twitchtv/twirp/pull/351

**Full Changelog**: https://github.com/twitchtv/twirp/compare/v8.1.1...v8.1.2

8.1.1

Changes:

- New supported client languages were added to the README: TwirpScript (Javascript/Typescript) [PR 331](https://github.com/twitchtv/twirp/pull/331) & [PR-334](https://github.com/twitchtv/twirp/pull/334), Swift [PR-337](https://github.com/twitchtv/twirp/pull/337)
- Add support for field presence in protobuf files [PR-332](https://github.com/twitchtv/twirp/pull/332). _Note: This is simply a feature flag to prevent `protoc` from returning an error when the option is used with twirp. No change to the generated code or runtime library was necessary._
- Don't check `error` when closing the response Body, [PR-336](https://github.com/twitchtv/twirp/pull/336). This works around an upstream issue in Go 1.16.10 and Go 1.17.3.
- New Error Constructors: `code.Error(msg)` and `code.Errorf(msg, a...)`. [PR-339](https://github.com/twitchtv/twirp/pull/339)
- Several minor doc changes: [PR 340](https://github.com/twitchtv/twirp/pull/340), [PR-343](https://github.com/twitchtv/twirp/pull/343), [PR 341](https://github.com/twitchtv/twirp/pull/341)

8.1.0

Changes:

* PR 323: Match service errors with `errors.As` instead of a type cast. Service implementations can now use their own error types if they implement the `twirp.Error` interface, but also if they wrap another Twirp error, or if theyimplement the method `As(interface{}) bool`. See docs on [Twirp Erros](https://twitchtv.github.io/twirp/docs/errors.html) for more details.
* PR 299: ServerOption `twirp.WithServerJSONCamelCaseNames(true)` configures JSON serialization to use the proto3 standard serialization method instead of the Twirp default to use the original proto names. When enabled, the JSON field names will be `lowerCamelCase` by default. If the `json_name` field option is used in the proto file, the specified value will be used as the key instead.
* PR 318: Removed example Python client generator. This repo contains the Go implementation only now.
* PR 319 refactors ServerOptions and ClientOptions to allow new options in the future without forcing version updates.
* PR 321 and 313 improves and simplifies the CI build process, running clientcompat tests and removing faulty coverage checks.
* PR 312 sorts generated code imports so the generator always produces the same output.

Update instructions:

* Required Go version `1.13+` is needed for the errors package [Is/As/Unwrap functions](https://golang.org/pkg/errors/).
* Runtime library is backwards compatible, can be safely updated to `v8.1.0`.
* Generated clients are backwards compatible, but will require the importer to update their Twirp runtime library.
* The PR 323 introduces a potential breaking change for services. Read below for safe update instructions.

Previous Twirp services (`v8.0.0` and older) check if returned errors are Twirp errors with a type-cast:
go
twerr, ok := err.(twirp.Error)

Newer Twirp services (`v8.1.0`) will check if returned errors are Twirp errors by matching with `errors.As`:
go
var twerr twirp.Error
ok := errors.As(err, &twerr)


Matching with `errors.As` is similar to the type-cast, but it can also unwrap errors of the same type. Before you update to version `v8.1.0`, please double check if any non-twirp errors returned by your service are not accidentally wrapping another Twirp error that should not be returned on the API. In particular, look for instances of `fmt.Errorf("foo: %w", twerr)`, using `%w` for wrapping other Twirp errors, for example:

go
// Calling another Twirp service from a Twirp method handler
resp, clientErr := anotherService.MyMethod(ctx, req)
if clientErr != nil {
// Wrapping another Twirp error will expose the inner error on v8.1.0
err := fmt.Errorf("otherService: %w", clientErr)
return nil, err
}


If you believe your service may be mistakenly wrapping other Twirp errors, you can explicitly wrap the error as an internal:
go
return nil, twirp.InternalErrorWith(err)


You could also use [this error hook](https://github.com/twitchtv/twirp/issues/300#issuecomment-860100481) to identify possible discrepancies before updating to the new version. In the other hand, if your service was already using idiomatic Go errors, the new implementation will give you more power to your own Twirp error implementations.

8.0.0

PR 304: Twirp v8 generates code that depends on Protobuf APIv2 (instead of APIv1).

Relevant links

* Protobuf APIv1 repo: https://github.com/golang/protobuf
* Protobuf APIv2 repo: https://github.com/protocolbuffers/protobuf-go
* Protobuf APIv2 release blog post: https://blog.golang.org/protobuf-apiv2
* Twirp version compatibility matrix: https://twitchtv.github.io/twirp/docs/version_matrix.html

Update Instructions

The runtime library `github.com/twitchtv/twirp` does not have any changes. The new generated code works with both old and new versions of the runtime library.

Re-generate code with Twirp v8 and Protobuf APIv2:

* Install the new protoc-gen-go plugin: `go install google.golang.org/protobuf/cmd/protoc-gen-golatest`.
* Install the new protoc-gen-twirp plugin: `go install github.com/twitchtv/twirp/protoc-gen-twirplatest`.
* Re-generate code. For example: `protoc --go_out=paths=source_relative:. --twirp_out=paths=source_relative:. service.proto`

See [Install docs](https://twitchtv.github.io/twirp/docs/install.html) for more information.

Generated clients and services will use the new imports: `google.golang.org/protobuf` (APIv2). Projects that make use of the generated clients/servers will have to update their import paths.

The new `google.golang.org/protobuf` (APIv2) is mostly backwards compatible, but not completely. You may have to make additional changes to work with the new protobuf library:

* In the proto file, the `option go_package` is mandatory and must include a "/" (it is supposed to be a full import path). If you have to add a full path to the go_package, you may want to generate with the options `paths=source_relative`. For example: `protoc --go_out=. --go_opt=paths=source_relative --twirp_out=. --twirp_opt=paths=source_relative myfile.proto`
* Generated message models (structs) now contain a mutex, your linter may complain if the models are copied by value. The solution is to pass pointers instead. Using `reflect.DeepEqual` will not be able to compare protobuf, you can use [proto.Equal](https://pkg.go.dev/google.golang.org/protobuf/proto#Equal) instead.
* Check [protobuf go compatibility](https://pkg.go.dev/google.golang.org/protobuf#readme-compatibility) and their [releases](https://github.com/protocolbuffers/protobuf-go/releases) for more details.

7.2.0

* PR 294: handling and returning valid error code for `context.Canceled` and `context.DeadlineExceeded` during body read error, and returning meaningful error 4XX instead of a 5XX error.

7.1.1

* PR 288

Page 1 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.