Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HackWeek] Add default values for (select) primitives and enums to the IR compiler #1615

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cflems
Copy link

@cflems cflems commented Aug 7, 2024

Before this PR

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==

@changelog-app
Copy link

changelog-app bot commented Aug 7, 2024

Generate changelog in changelog/@unreleased

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.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Add default values for primitives and enums to the IR compiler

Check the box to generate changelog(s)

  • Generate changelog entry

@cflems
Copy link
Author

cflems commented Aug 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants