generated from nyjc-computing/replit-flask-app
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
When required parameters are missing from POST requests, the API returns a 500 error with a KeyError instead of a proper 400 InvalidRequestError.
Location
- File:
campus/flask_campus/utils.py:76-78 - Affected Routes: Various POST endpoints with required parameters
Error
KeyError: "Missing required parameters: ['scopes', 'expiry_seconds']"
This KeyError is raised from unpack_into() and propagates as a 500 error instead of being caught and converted to a 400 InvalidRequestError.
Root Cause
In flask_campus/utils.py, the unpack_into() function raises a bare KeyError when required parameters are missing:
if missing_params:
raise (
KeyError(f"Missing required parameters: {missing_params}")
) from NoneThis should raise api_errors.InvalidRequestError instead to return a proper 400 status code.
Steps to Reproduce
# POST /credentials/{provider}/{user_id} without required body
POST /auth/v1/credentials/campus/user@example.com
Content-Type: application/json
Authorization: Bearer <token>
{} # Missing 'scopes' and 'expiry_seconds'Expected Behavior
Should return 400 with InvalidRequestError:
{
"error": "Missing required parameters: ['scopes', 'expiry_seconds']",
"error_code": "INVALID_REQUEST"
}Contract Test Blocked
tests/contract/test_auth_credentials.py::TestAuthCredentialsContract::test_create_credentials_missing_fields_returns_400is skipped due to this bug
Related
- Found during Phase 3 of integration test refactor
- HTTP contract test coverage expansion
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working