pypi connectrpc 0.12.0
v0.12.0

latest release: 0.12.1
one month ago

Important

This release includes two breaking changes to behavior. We expect the effect to be relatively limited but if you deal with large message payloads or use JSON encoding, read on for details.

Default incoming message size limit set to 4MB

Connect has always had an option read_max_bytes to limit the size of incoming messages with a default of no limit. This can allow requests to consume unbounded memory, particularly a concern if a server is exposed to external traffic without configuring this option. To reduce issues with default deployments though, we are changing the default limit to 4MB - this also aligns with gRPC's default. 4MB will likely be enough for many typical API payloads, but if you work with larger messages, you will need to raise the limit appropriately. Setting to None can disable the limit to preserve the old behavior, but this is strongly discouraged for servers that accept untrusted traffic. If your server accepts untrusted traffic, take care to configure this value to one appropriate for your workload.

Before

app = HaberdasherASGIApplication(MyHaberdasher())

After

# ONLY USE WITH HIGHLY TRUSTED TRAFFIC
app = HaberdasherASGIApplication(MyHaberdasher(), read_max_bytes=None)

JSON messages with unknown fields are allowed

Previously, if a server or client encountered a JSON message with fields not present in the schema that application was built against, the message would be rejected completely. This is not how other API server frameworks, including other Connect implementations, work and makes it difficult to incrementally evolve an API schema. Now, Connect will accept messages with unknown fields by default. Configure the JSON codec directly to preserve the previous behavior - in general, we don't recommend this to allow greater flexibility in iterating on your schema.

Before:

app = HaberdasherASGIApplication(MyHaberdasher())
client = HaberdasherClient("http://localhost")

After:

from connectrpc.codec import proto_binary_codec, proto_json_codec

app = HaberdasherASGIApplication(MyHaberdasher(), 
  codecs=[proto_binary_codec(), proto_json_codec(ignore_unknown_fields=False)]
)
client = HaberdasherClient("http://localhost", 
  codecs=[proto_binary_codec(), proto_json_codec(ignore_unknown_fields=False)]
)

📈 Enhancements

  • Avoid quadratic buffer copies in EnvelopeReader streaming path by @dongjiang1989 in #304
  • Render docstrings and expose service descriptor by @anuraaga in #305
  • Expose HTTP status code in ResponseMetadata by @anuraaga in #307
  • Use positional-only parameters for implemented protocols by @anuraaga in #311
  • Ignore unknown fields for JSON codec by default with knob by @anuraaga in #320
  • Set default read message limit to 4MB and check before compression by @anuraaga in #325
  • Apply message read limit during decompression by @anuraaga in #327
  • Execute metadata interceptors at the start of the chain before parsing request by @anuraaga in #328

Full Changelog: v0.11.1...v0.12.0

Don't miss a new connectrpc release

NewReleases is sending notifications on new releases.