Services using Conjure that wish to remain backwards-compatible while expanding their storage types must declare all new types as Optionals in order to avoid breaking Conjure's deserialization. This requires defaults to be declared in the implementation layer rather than in the API layer, in addition to creating a large number of useless box objects that bloat memory, and confusing the API spec with optional objects that are not actually optional. I personally have encountered bugs where a value was accidentally omitted from a "for backwards-compatibility only" in a storage type, causing developer hours to be wasted on something that should have been caught by the type system.
After this PR
FieldDefinitions in YAML now support a default parameter which accepts a value to supplied when null or empty values of this field are deserialized instead of throwing an error. Currently all primitive types (barring bearertokens and ANY) and enum values are supported. More complex types would work too, but the demand is small and I want to constrain the scope of this project.
==COMMIT_MSG==
Add default values for primitives and enums to the IR compiler
==COMMIT_MSG==
What do the change types mean?
- `feature`: A new feature of the service.
- `improvement`: An incremental improvement in the functionality or operation of the service.
- `fix`: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
- `break`: Has the potential to break consumers of this service's API, inclusive of both Palantir services
and external consumers of the service's API (e.g. customer-written software or integrations).
- `deprecation`: Advertises the intention to remove service functionality without any change to the
operation of the service itself.
- `manualTask`: Requires the possibility of manual intervention (running a script, eyeballing configuration,
performing database surgery, ...) at the time of upgrade for it to succeed.
- `migration`: A fully automatic upgrade migration task with no engineer input required.
_Note: only one type should be chosen._
How are new versions calculated?
- ❗The `break` and `manual task` changelog types will result in a major release!
- 🐛 The `fix` changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
- ✨ All others will result in a minor version release.
Enum aliases may need to die on second thought. I don't think we want the code gen to do Type.of(Type.of(Type.of(Type.of(Type.of(Type.of()))))) and I also don't think anyone wants it.
Before this PR
Services using Conjure that wish to remain backwards-compatible while expanding their storage types must declare all new types as
Optional
s in order to avoid breaking Conjure's deserialization. This requires defaults to be declared in the implementation layer rather than in the API layer, in addition to creating a large number of useless box objects that bloat memory, and confusing the API spec with optional objects that are not actually optional. I personally have encountered bugs where a value was accidentally omitted from a "for backwards-compatibility only" in a storage type, causing developer hours to be wasted on something that should have been caught by the type system.After this PR
FieldDefinitions in YAML now support a
default
parameter which accepts a value to supplied when null or empty values of this field are deserialized instead of throwing an error. Currently all primitive types (barring bearertokens andANY
) and enum values are supported. More complex types would work too, but the demand is small and I want to constrain the scope of this project.==COMMIT_MSG== Add default values for primitives and enums to the IR compiler ==COMMIT_MSG==