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

No way to indicate error during creation of custom challenge type #2356

Open
calebstewart opened this issue Jul 8, 2023 · 1 comment
Open

Comments

@calebstewart
Copy link

Currently, the challenge creation endpoint simply calls challenge_class.create(request) and assumes the request succeeds. The challenge's create class method could raise an HTTPException for input validation issues, but this feels like a hack in the larger context.

The answer may simply be defining an HTTPException subclass which implements the APISimpleErrorResponse schema, but I'm not sure if that's the best move.

If I've missed something that already exists to handle invalid challenge creation input, then I'd be happy to be corrected here. Thanks! :)

@ColdHeat
Copy link
Member

Yes it doesn't look like this is well defined in the code.

I think the smartest strategy would be to raise a custom exception that passes what the failing fields are as a dictionary. Then the API can return that dictionary in the overall response with success: False.

I don't think this strategy breaks anything so I can review/accept a PR for it whenever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants