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

[UBP] Fix usage gRPC sugar.ts file #12843

Merged
merged 2 commits into from
Sep 12, 2022
Merged

[UBP] Fix usage gRPC sugar.ts file #12843

merged 2 commits into from
Sep 12, 2022

Conversation

andrew-farries
Copy link
Contributor

Description

Fix the sugar.ts file that wraps the usage component gRPC client for typescript clients.

Use a return value of the correct shape rather than explicitly casting an incorrect shape.

In particular avoid the use of || against an enum type that can be 0.

See #12767 (comment) for the full context.

I really dislike these sugar files, they are an untested, handwritten layer over the generated gRPC client in which bugs like this can lurk.

Related Issue(s)

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

Andrew Farries added 2 commits September 9, 2022 14:42
In particular avoid the use of `||` against an enum type that can be 0.

See:

#12767 (comment)
@geropl
Copy link
Member

geropl commented Sep 9, 2022

I really dislike these sugar files, they are an untested, handwritten layer over the generated gRPC client in which bugs like this can lurk.

Definitely.

🔭 We could check out connect-web (link): it promises to generate usable TS code from gRPC protos.

Copy link
Member

@svenefftinge svenefftinge left a comment

Choose a reason for hiding this comment

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

I wonder why there are so many formatted changes. I thought we have the same formatting config set up on the workspaces.

return <CostCenter> {
id: AttributionId.parse(response.getCostCenter()!.getAttributionId()),

const attrId = AttributionId.parse(response.getCostCenter()!.getAttributionId());
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It would be a contract violation of the GRPC service to return a costCenter without an attributionID. We should enforce the contract in the API impl itself rather than on the TypeScript bindings.

@roboquat roboquat merged commit 2d3f0c3 into main Sep 12, 2022
@roboquat roboquat deleted the af/fix-usage-sugar-file branch September 12, 2022 06:00
@andrew-farries
Copy link
Contributor Author

I wonder why there are so many formatted changes. I thought we have the same formatting config set up on the workspaces.

It looked as though prettier had somehow not been run on the file, rather than a different prettier config.

@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants