Adopt error API to convey server errors to the client#151
Open
Hardikrepo wants to merge 1 commit into
Open
Conversation
Wire the new Apple_SwiftHomomorphicEncryption_Api_Pir_V1_Error protobuf message into PIRServiceController.queries(), replacing plain HTTPError throws with structured PIRServiceError cases. When a client's config id is stale, the server now embeds a fresh ConfigResponse in the error body so the client can retry immediately without a second round trip.
karulont
reviewed
Jul 1, 2026
karulont
left a comment
Contributor
There was a problem hiding this comment.
Thank you for the PR.
I expect there to be unit tests that cover this change.
| @@ -0,0 +1,67 @@ | |||
| // Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors | |||
Contributor
There was a problem hiding this comment.
This is a new file that was authored most likely in 2026, not during 2024 and then later changed in 2025.
Suggested change
| // Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors | |
| // Copyright 2026 Apple Inc. and the Swift Homomorphic Encryption project authors |
Contributor
There was a problem hiding this comment.
File name should probably be PIRServiceError, because this file contains the definition of it.
And the location of it should not be under Extensions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PIRServiceErrortype that serializes the newApple_SwiftHomomorphicEncryption_Api_Pir_V1_Errorprotobuf message (from Adding Error API swift-homomorphic-encryption-protobuf#21) as the HTTP response body, following the sameHTTPResponseErrorpattern already used forHeError/PirError.PIRServiceController.queries()to throwPIRServiceErrorinstead of plainHTTPError:invalidRequestevaluationKeyNotFoundconfigVersionNotFound, now with a freshConfigResponseembedded in the error body, so the client can retry immediately without a second config round trip (this is what Document database reloading functionality #94's linked comment asked for).config()into a sharedconfigResponse(usecases:existingConfigIds:context:)helper reused by both endpoints.Fixes #102.
Test plan
queriesrequest with a staleconfigurationHashand confirm the response body decodes asApple_SwiftHomomorphicEncryption_Api_Pir_V1_ErrorwithconfigVersionNotFound.configResponsepopulated