-
Notifications
You must be signed in to change notification settings - Fork 34
Update to latest conformance image #166
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
Conversation
…ce.swift Co-authored-by: Michael Rebello <me@michaelrebello.com>
| public init(from decoder: Swift.Decoder) throws { | ||
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
|
||
| // Read the base64-encoded payload and then pad if needed | ||
| let encodedPayload = try container.decode(String.self, forKey: .payload) | ||
| let padded = encodedPayload.padding( | ||
| toLength: ((encodedPayload.count+3)/4)*4, | ||
| withPad: "=", | ||
| startingAt: 0 | ||
| ) | ||
|
|
||
| self.init( | ||
| type: try container.decodeIfPresent(String.self, forKey: .type) ?? "", | ||
| payload: Data(base64Encoded: padded) | ||
| ) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rebello95 Here is the padding fix I mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do tests cover receiving both a padded and unpadded error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the conformance suite? If so, no, they don't account for that. But probably a good one to add when it's refactored.
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
|
||
| // Read the base64-encoded payload and then pad if needed | ||
| let encodedPayload = try container.decode(String.self, forKey: .payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a decodeIfPresent? This is changing behavior to throw if payload is omitted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely should. Fixed.
| public init(from decoder: Swift.Decoder) throws { | ||
| let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
|
||
| // Read the base64-encoded payload and then pad if needed | ||
| let encodedPayload = try container.decode(String.self, forKey: .payload) | ||
| let padded = encodedPayload.padding( | ||
| toLength: ((encodedPayload.count+3)/4)*4, | ||
| withPad: "=", | ||
| startingAt: 0 | ||
| ) | ||
|
|
||
| self.init( | ||
| type: try container.decodeIfPresent(String.self, forKey: .type) ?? "", | ||
| payload: Data(base64Encoded: padded) | ||
| ) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do tests cover receiving both a padded and unpadded error?
Co-authored-by: Michael Rebello <me@michaelrebello.com>
…ce.swift Co-authored-by: Michael Rebello <me@michaelrebello.com>
Co-authored-by: Michael Rebello <me@michaelrebello.com>
Co-authored-by: Michael Rebello <me@michaelrebello.com>
|
Would be nice to add tests for unpadded |
|
Agreed. I'll put a PR together for that. Thanks for reviewing! |
This updates the repo to use the latest conformance image, which uses the new organization on Dockerhub as well as the new proto packages (
connectrpc.conformance.v1instead ofgrpc.testing).As a part of this update, this attempts a fix at decoding the
ErrorDetailsvalue, which is returned as a base64-encoded string. The Connect protocol states that implementations should emit unpadded values and that downstream implementations should accept both padded and unpadded values. This adds padding to this string if needed as part of theConnectErrordecode logic.