liveBook · Manning

Schema mismatch

As explained in Troubleshooting Java, Second Edition

A schema mismatch is an incompatibility between the data structure expected by one service and the structure supplied by another.

A schema mismatch occurs when one service expects a data structure that another service supplies differently. Serialization turns in-memory objects into network bytes and reconstructs them on the receiving side, so mismatches can hide inside that transformation. section 12.2

Investigate mismatches by asking what changed and how the receiver interprets it:

  • Check whether a new JSON field is silently ignored by an older model. section 12.2
  • Check whether renamed Protobuf enums or non-optional fields alter compatibility. section 12.2
  • Look for dropped data, default values, or deserialization errors that appear only in particular circumstances. section 12.2
message Order {
  int64 id = 1;
  string customer_id = 2;
  repeated string items = 3;
  optional string notes = 4;
}

Use a small Protobuf schema to inspect how fields, optionality, and repeated values form a contract between services. section 12.2

Forward and backward compatibility let services evolve independently without accidentally breaking communication. Protobuf supplies stricter contracts than JSON or XML, but schema-based contracts still require careful evolution. section 12.2

How Troubleshooting Java, Second Edition covers it

How deep it goes
Explains serialization, compatibility risks, and observable symptoms, using JSON, Protobuf, and Java examples.
Examples
Uses added JSON fields, renamed Protobuf enums, optional fields, and incompatible Java serialVersionUID values.
What you can do after
Diagnose dropped data, default values, and deserialization errors while evaluating contract changes for compatibility.
How it connects
Connects schema mismatch with serialization, versioning, Protobuf, gRPC, JSON, XML, and forward and backward compatibility.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.