[{"id":"grpcadvanced-001","courseId":"grpc-advanced","domain":"message-schema","topic":"Edition 2023 syntax line","prompt":"A new .proto file has no edition or syntax line at its top. Which language version does the Protobuf compiler assume for it?","hint":"Think about which syntax the compiler treats as the baseline when nothing is declared.","explain":"Every .proto file can name its language version on one line near the top. Without that line, the compiler still needs a version to apply its rules, so it falls back to a built-in default.","source":"https://protobuf.dev/programming-guides/editions/","interaction":{"type":"single"},"options":[{"id":"a","text":"proto2","why":"With no edition or syntax line, the compiler assumes proto2."},{"id":"b","text":"proto3","whyNot":"proto3 applies only when the file declares it; it is not the fallback."},{"id":"c","text":"edition 2023","whyNot":"Edition 2023 applies only when the file declares it."},{"id":"d","text":"edition 2024","whyNot":"Edition 2024 is used only when the file's line selects it."}],"answer":"a","explanation":"A file with no edition or syntax line is treated as proto2; when an edition line is present, it must be the first non-empty, non-comment line.","concept":"A file with no edition or syntax line is treated as proto2; when an edition line is present, it must be the first non-empty, non-comment line.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["A .proto file with no edition or syntax line is read as proto2, so declare the version explicitly."]},{"id":"grpcadvanced-002","courseId":"grpc-advanced","domain":"message-schema","topic":"Field presence feature values","prompt":"The field below is set explicitly to its default value, 0, and the message is serialized. What reaches the wire for retries?","hint":"Ask whether the field keeps any record that it was assigned.","explain":"A field with presence tracking remembers that it was set, so the writer must send it even at the default. A field without presence tracking has no such memory.","source":"https://protobuf.dev/editions/features/","interaction":{"type":"single"},"options":[{"id":"a","text":"Nothing for retries: the default 0 is left off the wire","why":"IMPLICIT presence does not serialize the default value, even when the sender set it explicitly."},{"id":"b","text":"retries = 0 is written, since the sender set it","whyNot":"That is the behavior of explicit presence; IMPLICIT never writes the default value."},{"id":"c","text":"The serializer throws an error on the explicit 0","whyNot":"Nothing fails: an implicit field can hold 0, and the writer simply omits it."},{"id":"d","text":"retries = 0 is written only if has_retries() is true","whyNot":"IMPLICIT fields generate no has_ method, so there is no presence to check."}],"answer":"a","explanation":"Under IMPLICIT field presence the default value is not serialized onto the wire, even if it was explicitly set.","concept":"Under IMPLICIT field presence the default value is not serialized onto the wire, even if it was explicitly set.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"edition = \"2024\";\nmessage Settings {\n  int32 retries = 1\n    [features.field_presence = IMPLICIT];\n}","takeaways":["IMPLICIT fields generate no has_ functions and never write their default value."]},{"id":"grpcadvanced-003","courseId":"grpc-advanced","domain":"message-schema","topic":"Open and closed enums","prompt":"In edition 2024, this enum has no enum_type option. A message carries the number 9 for its color field, and no enumerator defines 9. Which TWO statements about that value are correct?","hint":"Ask where the number goes, and which setting controls that.","explain":"A proto enum must decide what happens to a number that matches no declared value. Each edition sets a default policy, and a file can override it with a feature.","source":"https://protobuf.dev/editions/features/","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"The field holds 9 directly, since open enums parse out-of-range values into their fields","why":"Edition 2024 enums default to OPEN, and open enums keep out-of-range values in the field itself."},{"id":"b","text":"With enum_type CLOSED, the 9 is kept in the message's unknown field set","why":"Closed enums store out-of-range values in the unknown field set instead of the field."},{"id":"c","text":"The parser rejects the whole message, since 9 matches no value","whyNot":"An out-of-range number is not a parse error; the open or closed setting decides where it goes."},{"id":"d","text":"The field is replaced by COLOR_UNSPECIFIED, the first value","whyNot":"The first value is the default only when the field is absent, not when a number is unrecognized."},{"id":"e","text":"Edition 2024 enums default to CLOSED, so 9 goes to unknown fields","whyNot":"The default for edition 2024 is OPEN; CLOSED is the default for proto2."},{"id":"f","text":"Only proto2 files can hold out-of-range enum values at all","whyNot":"Proto3 and edition 2024 enums are open by default, so they parse such values into the field."}],"answer":"ab","explanation":"Edition 2024 enums are open by default and parse out-of-range values into the field; with enum_type CLOSED, those values are stored in the unknown field set.","concept":"Edition 2024 enums are open by default and parse out-of-range values into the field; with enum_type CLOSED, those values are stored in the unknown field set.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"edition = \"2024\";\nenum Color {\n  COLOR_UNSPECIFIED = 0;\n  COLOR_RED = 1;\n  COLOR_BLUE = 2;\n}","takeaways":["Enum openness has a per-edition default, and the enum_type feature can override it."]},{"id":"grpcadvanced-004","courseId":"grpc-advanced","domain":"message-schema","topic":"Unknown fields in proto3","prompt":"A proto3 message is parsed from binary data that includes a field number its schema does not declare. When the message is serialized back to binary, that unknown field is written out again.","hint":"Think about what the parser does with bytes it cannot match to a declared field.","explain":"Parsers meet field numbers their schema does not declare. Whether that data survives depends on the format it travels in and on how the message is copied.","source":"https://protobuf.dev/programming-guides/proto3/","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"Proto3 messages preserve unknown fields during parsing and include them in the serialized output."},{"id":"b","text":"False","whyNot":"A common belief is that unknown fields are dropped; proto3 keeps them through parsing and serialization."}],"answer":"a","explanation":"Proto3 messages preserve unknown fields during parsing and include them in the serialized output, matching proto2 behavior.","concept":"Proto3 messages preserve unknown fields during parsing and include them in the serialized output, matching proto2 behavior.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Unknown fields survive binary round trips but are lost when a message is serialized to JSON."]},{"id":"grpcadvanced-005","courseId":"grpc-advanced","domain":"message-schema","topic":"Explicit defaults in proto2","prompt":"A proto2 message declares the field below. A sender leaves results_per_page out of the message entirely. What does the receiving code see?","hint":"Separate what a getter returns from whether the field was sent.","explain":"A getter can return a value for a field that the sender never set, so presence and value are tracked separately. Consider what a default does to each one.","source":"https://protobuf.dev/programming-guides/proto2/","interaction":{"type":"single"},"options":[{"id":"a","text":"The getter returns 10, and has_results_per_page() returns false","why":"The explicit default is returned by the getter, but the field is still reported as not present."},{"id":"b","text":"The getter returns 0, and has_results_per_page() returns false","whyNot":"The explicit default replaces the type's zero value for an unset field, so the getter returns 10."},{"id":"c","text":"The getter returns 10, and has_results_per_page() returns true","whyNot":"An unset field is not present; the default only affects what the getter reports."},{"id":"d","text":"The parser rejects the message, since the field is missing","whyNot":"An optional field may be absent, and leaving it out is not an error."}],"answer":"a","explanation":"In proto2, an unset optional field with an explicit default makes the getter return that default, while has-methods still report the field as not present.","concept":"In proto2, an unset optional field with an explicit default makes the getter return that default, while has-methods still report the field as not present.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"syntax = \"proto2\";\nmessage SearchRequest {\n  optional int32 results_per_page = 3\n    [default = 10];\n}","takeaways":["In proto2, use the has-method to check whether a field was sent; the getter alone cannot tell you."]}]