Skip to content

Commit

Permalink
Return 404 error when LPA is not retrieved VEGA-2203 #minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Iqpal Mannan committed Dec 15, 2023
1 parent 9e842e7 commit 8fbe7e8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
29 changes: 29 additions & 0 deletions docs/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/BadRequestError"
"404":
description: Case not found.
content:
application/json:
schema:
$ref: "#/components/schemas/NotFoundError"
x-amazon-apigateway-auth:
type: "AWS_IAM"
x-amazon-apigateway-integration:
Expand Down Expand Up @@ -189,6 +195,29 @@ components:
example:
- source: "/uid"
detail: "invalid uid format"
NotFoundError:
allOf:
- $ref: "#/components/schemas/AbstractError"
- type: object
properties:
code:
enum: ["NOT_FOUND"]
errors:
type: array
items:
type: object
required:
- source
- detail
properties:
source:
type: string
format: jsonpointer
detail:
type: string
example:
- source: "/uid"
detail: "uid not found"
Lpa:
allOf:
- $ref: "#/components/schemas/InitialLpa"
Expand Down
6 changes: 6 additions & 0 deletions internal/shared/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ var ProblemUnauthorisedRequest Problem = Problem{
Detail: "Invalid JWT",
}

var ProblemNotFoundRequest Problem = Problem{
StatusCode: 404,
Code: "NOT_FOUND",
Detail: "Record not found",
}

func (problem Problem) Respond() (events.APIGatewayProxyResponse, error) {
var errorString = ""
for _, ve := range problem.Errors {
Expand Down
2 changes: 1 addition & 1 deletion lambda/get/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe

if err != nil {
l.logger.Print(err)
return shared.ProblemInternalServerError.Respond()
return shared.ProblemNotFoundRequest.Respond()
}

body, err := json.Marshal(lpa)
Expand Down

0 comments on commit 8fbe7e8

Please sign in to comment.