Skip to content

Generate error result types in Dialogue interfaces for endpoints with associated errors #2435

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

Merged
merged 24 commits into from
Mar 3, 2025

Conversation

mpritham
Copy link
Contributor

@mpritham mpritham commented Jan 15, 2025

Before this PR

In #2401, we added the ability to associate errors with endpoints so servers could throw checked exceptions (extensions of CheckedServiceException). Clients still catch RemoteExceptions.

After this PR

Dialogue client interface methods for endpoints which have associated errors will return result types - implemented as sealed interfaces permitting a successful result member, and a member for each error. This enforces that clients handle all errors an endpoint can throw at compile time.

Examples of generated code are given here

This feature should be used with Java 21 to make use of the exhaustive pattern matching switch feature.

==COMMIT_MSG==
Generate error result types in Dialogue interfaces for endpoints with associated errors
==COMMIT_MSG==

Possible downsides?

If not rolled out judiciously, this feature may result in compile breaks. Concretely, if a service enables this feature and publishes JARs containing the generated Dialogue clients, consumers of the JARs will be forced to resolve the compile breaks they encounter when using the Dialogue clients.

@changelog-app
Copy link

changelog-app bot commented Jan 15, 2025

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

Generate error result types in Dialogue interfaces for endpoints with associated errors

Check the box to generate changelog(s)

  • Generate changelog entry

@mpritham mpritham force-pushed the pm/client-errors-result-type branch 7 times, most recently from a27142a to 24459fe Compare January 21, 2025 16:51
@mpritham mpritham force-pushed the pm/client-errors-result-type branch 3 times, most recently from cf12ba8 to e2e13e6 Compare January 24, 2025 03:34
@mpritham mpritham changed the title [do-not-merge] client error result types Client error result types Jan 24, 2025
@mpritham mpritham force-pushed the pm/client-errors-result-type branch from e2e13e6 to 692ebf4 Compare January 24, 2025 16:20
@mpritham mpritham force-pushed the pm/client-errors-result-type branch from 692ebf4 to a4ba764 Compare January 24, 2025 16:37
Copy link
Contributor

@carterkozak carterkozak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some end-to-end tests using a conjure-undertow service producing failures, and a dialogue client handling them to make sure the pieces fit together in practice!

@mpritham mpritham force-pushed the pm/client-errors-result-type branch from 3b8f4fd to 602b331 Compare January 28, 2025 16:22
@mpritham mpritham marked this pull request as ready for review February 4, 2025 15:37
@mpritham mpritham force-pushed the pm/client-errors-result-type branch from 584a5e6 to 619e6dc Compare February 4, 2025 15:43
carterkozak
carterkozak previously approved these changes Feb 4, 2025
Copy link
Contributor

@carterkozak carterkozak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving for a release candidate!

@policy-bot policy-bot bot dismissed carterkozak’s stale review February 4, 2025 17:07

Invalidated by push of 5e9a237

@mpritham mpritham force-pushed the pm/client-errors-result-type branch from 3e4c749 to 2797feb Compare February 24, 2025 19:56
@bulldozer-bot bulldozer-bot bot merged commit e7b3586 into develop Mar 3, 2025
4 of 5 checks passed
@bulldozer-bot bulldozer-bot bot deleted the pm/client-errors-result-type branch March 3, 2025 22:39
@autorelease3
Copy link

autorelease3 bot commented Mar 3, 2025

Released 8.44.0

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

Successfully merging this pull request may close these issues.

4 participants