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

VEGA-2203 LPA Store returns 500 if it can't find an LPA #74

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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"
iqpalm marked this conversation as resolved.
Show resolved Hide resolved
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()
iqpalm marked this conversation as resolved.
Show resolved Hide resolved
}

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