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

Refactor credential issuer metadata resolver api #76

Conversation

srosenda
Copy link
Contributor

@srosenda srosenda commented Sep 11, 2024

Description of change

CredentialIssuerMetadataType protocol has API issues that make it hard to use and its only implementation CredentialIssuerMetadataResolver can be improved too.

List of improvements I propose in this PR:

  • a823c22: Change the CredentialIssuerMetadataType.resolve(source:) parameter type to non-optional. There is no value for it being optional as the implementation cannot do anything but return an error if the source is not defined.
  • 999fb63: Change CredentialIssuerMetadataType.resolve function's Success result type to non-optional. The use of Result as the return type already provides a channel for errors and it is unclear what the result .success(nil) should even mean from the client perspective, but all clients had to handle the "empty" result anyway. Furthermore the only implementation CredentialIssuerMetadataResolver.resolve did not have a control flow that would have returned .success(nil) in any case.
  • d71a97e: Do not mask Fetcher error in CredentialIssuerMetadataResolver.resolve. If there was an error fetching the metadata the error returned by the Fetcher was thrown away (converted to nil with try? result.get()) and a generic ValidationError.error(reason: "Unable to retrieve metadata") was returned instead. This makes it hard to detect or debug what the actual error was when fetching the metadata and it is better not to mask the error and there is no reason to map it to some other error type either. Also ValidationError does not sound like a good match for e.g. a network error returned by the Fetcher. Omitting the error mapping also streamlines the resolve implementation significantly, as it can directly return the Fetcher's result.
  • c4f8444: Inline the locally defined URL path constants in CredentialIssuerMetadataResolver.resolve. The constants have only a single use site and inlining them makes it more obvious in the code in what order the components are appended to the path.

Type of change

Please delete options that are not relevant.

  • Breaking change: clients of CredentialIssuerMetadataType.resolve(source:) need to remove the nil checking of success result.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Passes the automated test suite of the project

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the readme
  • My changes generate no new warnings
  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@srosenda srosenda requested a review from a team as a code owner September 11, 2024 14:56
@srosenda srosenda changed the title Refactor/credential issuer metadata resolver api Refactor credential issuer metadata resolver api Sep 13, 2024
@dtsiflit dtsiflit merged commit 5483f37 into eu-digital-identity-wallet:main Oct 10, 2024
3 checks passed
@srosenda srosenda deleted the refactor/CredentialIssuerMetadataResolver-api branch October 24, 2024 07:16
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