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

fix(backend): fixing response status code for grpc request #2741

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/grpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ components:

GRPCResponse:
type: object
required:
- statusCode
properties:
statusCode:
type: integer
default: 0
metadata:
type: array
items:
Expand Down
37 changes: 15 additions & 22 deletions cli/openapi/model_grpc_response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion server/openapi/model_grpc_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package openapi

type GrpcResponse struct {
StatusCode int32 `json:"statusCode,omitempty"`
StatusCode int32 `json:"statusCode"`

Metadata []GrpcHeader `json:"metadata,omitempty"`

Expand All @@ -19,6 +19,15 @@ type GrpcResponse struct {

// AssertGrpcResponseRequired checks if the required fields are not zero-ed
func AssertGrpcResponseRequired(obj GrpcResponse) error {
elements := map[string]interface{}{
"statusCode": obj.StatusCode,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {
return &RequiredError{Field: name}
}
}

for _, el := range obj.Metadata {
if err := AssertGrpcHeaderRequired(el); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions web/src/models/TriggerResult.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ResponseData = {
return {
body: get(response, 'body', ''),
headers: get(response, 'metadata', undefined) as THeader[],
statusCode: get(response, 'statusCode', 200),
statusCode: get(response, 'statusCode', 0),
};
},
[TriggerTypes.traceid](response: object) {
Expand All @@ -38,7 +38,7 @@ const ResponseData = {

const TriggerResult = ({
triggerType = 'http',
triggerResult: {http = {}, grpc = {}, traceid = {}} = {},
triggerResult: {http = {}, grpc = {statusCode: 0}, traceid = {}} = {},
}: TRawTriggerResult): TriggerResult => {
const type = triggerType as TriggerTypes;

Expand Down
2 changes: 1 addition & 1 deletion web/src/types/Generated.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ export interface external {
request?: string;
};
GRPCResponse: {
statusCode?: number;
statusCode: number;
metadata?: external["grpc.yaml"]["components"]["schemas"]["GRPCHeader"][];
body?: string;
};
Expand Down