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

POST Key Event - exception handler #359

Open
iustinp opened this issue Jun 14, 2024 · 4 comments
Open

POST Key Event - exception handler #359

iustinp opened this issue Jun 14, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@iustinp
Copy link

iustinp commented Jun 14, 2024

Description
Trying to create a new key event of a type other than the existing ones, will result in request timing out.

To Reproduce
E.g. Try adding a key of type: "type"

Expected behavior
Request should return an error.

@iustinp iustinp added the bug Something isn't working label Jun 14, 2024
@AndreiAlexandruParaschiv
Copy link
Contributor

hey @iustinp, this shouldn't happen as there is a validation check for types in place here: https://github.com/adobe/spacecat-shared/blob/6bed3412af558946575f9f6be6d313ff0511db40/packages/spacecat-shared-data-access/src/models/key-event.js#L68-L70
In case a type is not in the KEY_EVENT_TYPES set, it will throw an error like below:


{
	"message": "Unknown value for \"type\": type"
}

The status code is 500 Internal Server error but it should a 400 - Bad Request as the type is incorrect.

@iustinp
Copy link
Author

iustinp commented Jun 26, 2024

Hello! Indeed, i was able to see that the timeout-like behaviour is induced by Power Automate HTTP request action, because while the response from the spacecat API is instant (with the details you provided), the automation only fails after ~25minutes.
I will add extra checks on my side and also look to optimise the flow to throw such errors much faster.
In the meantime this probably can stay up for the wrong status code.
Thank you for looking into this!

@AndreiAlexandruParaschiv AndreiAlexandruParaschiv changed the title Key Event POST new event with non-existent Type will timeout POST Key Event - exception handler for BadRequest Jul 9, 2024
@AndreiAlexandruParaschiv
Copy link
Contributor

AndreiAlexandruParaschiv commented Jul 9, 2024

Updated the title for this ticket

The approach is to have an exceptionHandler (that extends the Error class) to throw the adequate error (400 for BadRequest)
Created the PR's

@AndreiAlexandruParaschiv
Copy link
Contributor

@iuliag @ekremney Wdyt about this approach? ⬆️

@AndreiAlexandruParaschiv AndreiAlexandruParaschiv changed the title POST Key Event - exception handler for BadRequest POST Key Event - exception handler Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants