Open clord opened 1 month ago
@clord thanks for this - the 'required' thing in Grafana Incident is handled via the comment metadata mechanism in Oto. The templates check that field and render appropriate validation output. So I think this would be best solved in the templates themselves, and you don't need to change Oto to do it. Oto doesn't have any specific support for 'required' fields.
Template changes will be required, but this request is for something between optional
and required
. When introducing a new field, or removing it, we want the validation of the producer to be required
, but the validation of the consumer to be optional
. This way, we start producing it asap, but we don't have to validate it yet on the consumer. imo, we want to break the two 'sides' of required
up up so template can know which case we are in.
Problem
Modifying required fields in our API can lead to compatibility issues between clients and servers, especially when fields are added, removed, or have their required/optional status changed. The key challenges are:
Making all fields optional is not a feasible solution because:
Proposal: Transitional Field Statuses
Implement transitional statuses for fields to manage their lifecycle without breaking existing client/servers:
becoming-required
— introducing a new field that will eventually become requiredbecoming-optional
— planning to deprecate and eventually remove an existing required fieldThis approach allows for a gradual transition.
becoming-required
to ensure writers start including it while readers remain compatible with data that may not contain it. Once all writers are updated, we can then mark the field asrequired
, so that clients can begin assuming it's always present.becoming-optional
to signal that it will eventually be removed, allowing readers to adjust without immediate impact on writers. Once all readers are updated to no longer expect the field, we can remove the field, and writers can stop emitting the field.Reader/Writer vs Client/Server
Please note the distinction between client/server and reader/writer. Both clients and servers write to structs, and read from structs. In this PR we draw the distinction instead between readers and writers.