Stubs

Reference

Breaking-change rules

stubs breaking compares a workspace with an earlier version of it (a Git branch, a module on Stubs, or an image) and reports changes that would break the code or the data that use it: the same checks Stubs runs for an organisation's breaking-change policy (see Governance). Choose them in breaking in stubs.yaml by category or by ID, and list them with stubs config ls-breaking-rules.

A rule's anchor is its ID, so /docs/breaking-rules#FIELD_NO_DELETE and #field_no_delete both lead to it.

Categories

Choose the category that matches how your schemas are used. Each rule below lists the categories it's in.

FILE and PACKAGE

For code generated from your schemas. FILE (the default) breaks on anything that changes generated code, file by file: a type moving to another file breaks it, since in many languages each file is its own unit. PACKAGE allows moves between files of the same package, for languages that generate per package (Go, for one).

WIRE and WIRE_JSON

For data, not code: changes that would stop existing messages being read. WIRE_JSON keeps both the binary encoding and the JSON encoding readable, so field names matter as well as numbers. WIRE only keeps the binary encoding readable, so renaming a field is fine, but renumbering it isn't.

CSR

For schemas registered with Confluent Schema Registry: the changes its Protobuf compatibility checks would refuse. Use it to check a schema here before it reaches a Kafka topic.

The categories overlap rather than nest: a rule about generated code is only in FILE or PACKAGE, and one about JSON only in WIRE_JSON. Pick one, or combine them with use.

Unstable packages

ignore_unstable_packages: true skips packages whose version is unstable (v1alpha1, v1beta1, v1test …), which are expected to change.

Rules

EXTENSION_NO_DELETE

Extensions aren't removed from a file. Code that sets or reads them stops compiling.

Categories: FILE. Not in v1 or v1beta1 configs.

SERVICE_NO_DELETE

Services aren't removed from a file. Clients and servers generated from it stop compiling.

Categories: FILE.

ENUM_NO_DELETE

Enums aren't removed from a file. Code that uses them stops compiling.

Categories: CSR, FILE. In v1 configs: FILE. In v1beta1 configs: FILE.

FILE_NO_DELETE

Files aren't removed. Imports of the file break, and so does generated code that refers to its types.

Categories: CSR, FILE. In v1 configs: FILE. In v1beta1 configs: FILE.

MESSAGE_NO_DELETE

Messages aren't removed from a file. Code that uses them stops compiling.

Categories: CSR, FILE. In v1 configs: FILE. In v1beta1 configs: FILE.

ENUM_SAME_TYPE

An enum stays open or closed. A closed enum (proto2's) keeps unknown values out of the field, and an open one (proto3's) lets them in, so switching changes what readers see for values they don't know.

Categories: FILE, PACKAGE.

FIELD_SAME_CARDINALITY

A field stays singular, optional, repeated or required. Changing it changes the generated accessors, so code using them stops compiling.

Categories: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

FIELD_SAME_CPP_STRING_TYPE

A string field's C++ type (ctype, or the (pb.cpp).string_type feature) stays the same, so generated C++ keeps its accessor types.

Categories: FILE, PACKAGE.

FIELD_SAME_JAVA_UTF8_VALIDATION

A string field's Java UTF-8 checking (java_string_check_utf8, or the (pb.java).utf8_validation feature) stays the same. Turning it on makes Java reject strings it used to accept.

Categories: FILE, PACKAGE.

FIELD_SAME_JSTYPE

A 64-bit field's jstype stays the same. It decides whether JavaScript sees the value as a string or a number, so changing it changes the field's type in JavaScript code.

Categories: FILE, PACKAGE.

FIELD_SAME_UTF8_VALIDATION

A string field's UTF-8 validation (the utf8_validation feature) stays the same. Turning it on makes readers reject messages they used to accept.

Categories: FILE, PACKAGE.

FILE_SAME_CC_ENABLE_ARENAS

A file's cc_enable_arenas stays the same, so generated C++ keeps its memory API.

Categories: FILE, PACKAGE.

FILE_SAME_CC_GENERIC_SERVICES

A file's cc_generic_services stays the same, so the C++ service classes it generates don't appear or vanish.

Categories: FILE, PACKAGE.

FILE_SAME_CSHARP_NAMESPACE

A file's csharp_namespace stays the same, so its C# types keep their names.

Categories: FILE, PACKAGE.

FILE_SAME_GO_PACKAGE

A file's go_package stays the same, so its Go code keeps its import path and package name.

Categories: FILE, PACKAGE.

FILE_SAME_JAVA_GENERIC_SERVICES

A file's java_generic_services stays the same, so the Java service classes it generates don't appear or vanish.

Categories: FILE, PACKAGE.

FILE_SAME_JAVA_MULTIPLE_FILES

A file's java_multiple_files stays the same. It decides whether each type is a top-level Java class or nested in the file's outer class, so changing it renames every type.

Categories: FILE, PACKAGE.

FILE_SAME_JAVA_OUTER_CLASSNAME

A file's java_outer_classname stays the same, so its Java outer class keeps its name.

Categories: FILE, PACKAGE.

FILE_SAME_JAVA_PACKAGE

A file's java_package stays the same, so its Java classes keep their package.

Categories: FILE, PACKAGE.

FILE_SAME_OBJC_CLASS_PREFIX

A file's objc_class_prefix stays the same, so its Objective-C classes keep their names.

Categories: FILE, PACKAGE.

FILE_SAME_OPTIMIZE_FOR

A file's optimize_for stays the same. LITE_RUNTIME and SPEED generate different APIs, and code built against one may not compile against the other.

Categories: FILE, PACKAGE.

FILE_SAME_PHP_CLASS_PREFIX

A file's php_class_prefix stays the same, so its PHP classes keep their names.

Categories: FILE, PACKAGE.

FILE_SAME_PHP_METADATA_NAMESPACE

A file's php_metadata_namespace stays the same, so its PHP metadata class keeps its name.

Categories: FILE, PACKAGE.

FILE_SAME_PHP_NAMESPACE

A file's php_namespace stays the same, so its PHP classes keep their namespace.

Categories: FILE, PACKAGE.

FILE_SAME_PY_GENERIC_SERVICES

A file's py_generic_services stays the same, so the Python service classes it generates don't appear or vanish.

Categories: FILE, PACKAGE.

FILE_SAME_RUBY_PACKAGE

A file's ruby_package stays the same, so its Ruby classes keep their module.

Categories: FILE, PACKAGE.

FILE_SAME_SWIFT_PREFIX

A file's swift_prefix stays the same, so its Swift types keep their names.

Categories: FILE, PACKAGE.

RPC_NO_DELETE

RPCs aren't removed from a service. Clients calling them start failing, and servers stop compiling.

Categories: FILE, PACKAGE.

ENUM_VALUE_NO_DELETE

Enum values aren't removed. Code using the value stops compiling, and its number could later be reused with another meaning.

Categories: CSR, FILE, PACKAGE. In v1 configs: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE.

EXTENSION_MESSAGE_NO_DELETE

A message's extension ranges aren't removed. Extensions declared in them elsewhere would no longer be valid.

Categories: CSR, FILE, PACKAGE. In v1 configs: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE.

FIELD_NO_DELETE

Fields aren't removed. Code using the field stops compiling, and its number could later be reused, so old data would be read as the new field. To retire one, deprecate it, or remove it and reserve its number and name.

Categories: CSR, FILE, PACKAGE. In v1 configs: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE.

FIELD_SAME_TYPE

A field keeps its type. Changing it breaks generated code, and in most cases the data already written.

Categories: CSR, FILE, PACKAGE. In v1 configs: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

FILE_SAME_SYNTAX

A file keeps its syntax or edition. Moving between proto2, proto3 and Editions changes defaults such as field presence and enum openness, and so how data and code behave.

Categories: CSR, FILE, PACKAGE. In v1 configs: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE.

MESSAGE_NO_REMOVE_STANDARD_DESCRIPTOR_ACCESSOR

A message doesn't switch no_standard_descriptor_accessor on, which removes the descriptor() accessor from its generated code.

Categories: CSR, FILE, PACKAGE. In v1 configs: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE.

ONEOF_NO_DELETE

Oneofs aren't removed from a message. Code using the oneof's generated accessors stops compiling.

Categories: CSR, FILE, PACKAGE. In v1 configs: FILE, PACKAGE. In v1beta1 configs: FILE, PACKAGE.

ENUM_SAME_JSON_FORMAT

An enum's JSON support (the json_format feature) stays the same, so it can still be written and read as JSON.

Categories: CSR, FILE, PACKAGE, WIRE_JSON. In v1 configs: FILE, PACKAGE, WIRE_JSON. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON.

ENUM_VALUE_SAME_NAME

An enum value keeps its name. Its number doesn't change on the wire, but JSON writes the name, so readers expecting the old one can't parse it.

Categories: CSR, FILE, PACKAGE, WIRE_JSON. In v1 configs: FILE, PACKAGE, WIRE_JSON. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON.

FIELD_SAME_JSON_NAME

A field's json_name stays the same. It's the key in JSON, so readers looking for the old key miss the value.

Categories: CSR, FILE, PACKAGE, WIRE_JSON. In v1 configs: FILE, PACKAGE, WIRE_JSON. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON.

FIELD_SAME_NAME

A field keeps its name. The binary encoding uses only the number, but JSON uses the name, and generated code is named after it.

Categories: CSR, FILE, PACKAGE, WIRE_JSON. In v1 configs: FILE, PACKAGE, WIRE_JSON. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON.

MESSAGE_SAME_JSON_FORMAT

A message's JSON support (the json_format feature) stays the same, so it can still be written and read as JSON.

Categories: CSR, FILE, PACKAGE, WIRE_JSON. In v1 configs: FILE, PACKAGE, WIRE_JSON. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON.

FIELD_SAME_DEFAULT

A field's default (proto2 and Editions) stays the same. It's what readers see when the field isn't set, so changing it changes the meaning of every message that left it out.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. Not in v1 or v1beta1 configs.

FIELD_SAME_ONEOF

A field stays in the same oneof, or out of any. Moving it changes what setting it clears, so the same data can read differently.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

FILE_SAME_PACKAGE

A file keeps its package. Every type's full name includes the package, and full names are on the wire: in google.protobuf.Any, in RPC paths, and in what servers expect.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE.

MESSAGE_SAME_REQUIRED_FIELDS

A message gains or loses no required fields. A reader rejects a message without one of its required fields, so either change makes some messages unreadable by some readers.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

RESERVED_ENUM_NO_DELETE

An enum's reserved numbers and names stay reserved. They're reserved so a removed value's number or name can't be reused for something else.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

RESERVED_MESSAGE_NO_DELETE

A message's reserved numbers and names stay reserved. They're reserved so a removed field's number or name can't be reused for something else.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

RPC_SAME_CLIENT_STREAMING

An RPC keeps whether it streams requests. Clients and servers on either side of the change can't talk to each other.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

RPC_SAME_IDEMPOTENCY_LEVEL

An RPC's idempotency_level stays the same. It decides, for one, whether Connect clients may call the RPC with an HTTP GET, so changing it can turn working calls away.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

RPC_SAME_REQUEST_TYPE

An RPC keeps its request message. Clients sending the old one would be misread.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

RPC_SAME_RESPONSE_TYPE

An RPC keeps its response message. Clients expecting the old one would misread the reply.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

RPC_SAME_SERVER_STREAMING

An RPC keeps whether it streams responses. Clients and servers on either side of the change can't talk to each other.

Categories: CSR, FILE, PACKAGE, WIRE_JSON, WIRE. In v1 configs: FILE, PACKAGE, WIRE_JSON, WIRE. In v1beta1 configs: FILE, PACKAGE, WIRE_JSON, WIRE.

PACKAGE_ENUM_NO_DELETE

Enums aren't removed from a package. Moving one to another file of the same package is fine.

Categories: PACKAGE.

PACKAGE_EXTENSION_NO_DELETE

Extensions aren't removed from a package. Moving one to another file of the same package is fine.

Categories: PACKAGE. Not in v1 or v1beta1 configs.

PACKAGE_MESSAGE_NO_DELETE

Messages aren't removed from a package. Moving one to another file of the same package is fine.

Categories: PACKAGE.

PACKAGE_NO_DELETE

Packages aren't removed: some file still declares every package that was there before.

Categories: PACKAGE.

PACKAGE_SERVICE_NO_DELETE

Services aren't removed from a package. Moving one to another file of the same package is fine.

Categories: PACKAGE.

ENUM_VALUE_NO_DELETE_UNLESS_NAME_RESERVED

An enum value is only removed if its name is reserved, so the name can't come back with another number and be misread in JSON.

Categories: CSR, WIRE_JSON. In v1 configs: WIRE_JSON. In v1beta1 configs: WIRE_JSON.

FIELD_NO_DELETE_UNLESS_NAME_RESERVED

A field is only removed if its name is reserved, so the name can't come back with another number and be misread in JSON.

Categories: CSR, WIRE_JSON. In v1 configs: WIRE_JSON. In v1beta1 configs: WIRE_JSON.

FIELD_WIRE_JSON_COMPATIBLE_CARDINALITY

A field's cardinality only changes in ways that keep both binary and JSON data readable.

Categories: CSR, WIRE_JSON. In v1 configs: WIRE_JSON. In v1beta1 configs: WIRE_JSON.

FIELD_WIRE_JSON_COMPATIBLE_TYPE

A field's type only changes in ways that keep both binary and JSON data readable. Fewer changes qualify than for binary alone: string to bytes, for one, reads fine in binary but not in JSON, where bytes is base64.

Categories: CSR, WIRE_JSON. In v1 configs: WIRE_JSON. Not in v1beta1 configs.

ENUM_VALUE_NO_DELETE_UNLESS_NUMBER_RESERVED

An enum value is only removed if its number is reserved, so the number can't be reused for another value.

Categories: CSR, WIRE_JSON, WIRE. In v1 configs: WIRE_JSON, WIRE. In v1beta1 configs: WIRE_JSON, WIRE.

FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED

A field is only removed if its number is reserved, so the number can't be reused and old data misread as the new field.

Categories: CSR, WIRE_JSON, WIRE. In v1 configs: WIRE_JSON, WIRE. In v1beta1 configs: WIRE_JSON, WIRE.

FIELD_WIRE_COMPATIBLE_CARDINALITY

A field's cardinality only changes in ways that keep binary data readable, such as between singular and optional.

Categories: WIRE.

FIELD_WIRE_COMPATIBLE_TYPE

A field's type only changes to one encoded the same way in binary: among int32, uint32, int64, uint64 and bool; between sint32 and sint64; or between string and bytes, for example. Values that don't fit the new type are truncated, so check the range.

Categories: WIRE. Not in v1beta1 configs.

MESSAGE_SAME_MESSAGE_SET_WIRE_FORMAT

A message's message_set_wire_format stays the same. It changes how the message is encoded, so data written one way can't be read the other.

Categories: none. Deprecated: kept so configs that name it still work.

FIELD_SAME_CTYPE

A field's ctype stays the same. Replaced by FIELD_SAME_CPP_STRING_TYPE, which also covers the Editions feature.

Categories: none (in v1 configs; not in v2). Deprecated: use FIELD_SAME_CPP_STRING_TYPE instead.

FIELD_SAME_LABEL

A field's label (optional, repeated, required) stays the same. Replaced by the cardinality rules, which understand Editions' field presence.

Categories: none (in v1 configs; not in v2). Deprecated: use FIELD_SAME_CARDINALITY, FIELD_WIRE_COMPATIBLE_CARDINALITY and FIELD_WIRE_JSON_COMPATIBLE_CARDINALITY instead.

FILE_SAME_JAVA_STRING_CHECK_UTF8

A file's java_string_check_utf8 stays the same. Replaced by FIELD_SAME_JAVA_UTF8_VALIDATION, which also covers the Editions feature.

Categories: none (in v1 configs; not in v2). Deprecated: use FIELD_SAME_JAVA_UTF8_VALIDATION instead.

FILE_SAME_PHP_GENERIC_SERVICES

A file's php_generic_services stays the same. The option has since been removed from Protobuf.

Categories: none (in v1 configs; not in v2). Deprecated: kept so configs that name it still work.