CS FundamentalsVery hardProduct-company placement
A gRPC API's Protocol Buffers message had field 'int32 discount = 4', which was deleted last year. A developer now adds 'string coupon = 4'. Why is this dangerous, and what is the safe practice?
- A. Field numbers must always increase, so the build fails
- B. Protobuf fields cannot be strings
- C. It is safe, because protobuf ignores type information on the wire
- D. Old clients or stored data still using tag 4 as an int32 will be misread as the new string field; deleted numbers should be marked reserved and new fields get fresh numbers
Correct answer: D. Old clients or stored data still using tag 4 as an int32 will be misread as the new string field; deleted numbers should be marked reserved and new fields get fresh numbers
The wire format identifies fields by number and wire type, not name, so reusing 4 makes old producers' data collide with the new field (parse errors or garbage). Adding fields with new numbers and reserving retired ones keeps compatibility both ways.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- For monitoring, which pairing of method and what it tracks is correct?
- A service receives 2000 requests per second; each request holds a worker thread for 150 ms on average. It runs on 4 identical instances…
- A request flows client → A → B → C → D. Services A, B and C each make up to 3 attempts (1 + 2 retries) when their downstream call fails. D…
- A web API's documentation says nothing about the order of items in a JSON list, which happened to be sorted by id. After an internal…
- A dependency-injection container registers ReportCache as a singleton, and ReportCache takes a DbSession in its constructor; DbSession is…
- Counting each if, loop header, and/or operator, conditional expression and except clause as one decision (V(G) = decisions + 1), what is…