Skip to content

Add null check for request.json in market_holidays, symbol, and intervals endpoints #1015

@marketcalls

Description

@marketcalls

Description

Several API endpoints pass `request.json` directly to schema validation without checking if it's `None`. If a client sends a request with no JSON body or incorrect Content-Type, this results in an unhandled error instead of a clean error response.

Affected Files

  • `restx_api/market_holidays.py` (line 30)
  • `restx_api/symbol.py` (line 30)
  • `restx_api/intervals.py` (line 31)

Reference Implementation

`restx_api/option_greeks.py` (line 84) already handles this correctly:

```python
if request.json is None:
return make_response(jsonify({
"status": "error",
"message": "Request body must be JSON"
}), 400)

data = schema.load(request.json)
```

What to Do

  1. Add the null check before schema validation in each affected file
  2. Follow the pattern from `option_greeks.py`

Acceptance Criteria

  • All three files validate `request.json` is not None
  • Returns 400 with clear error message for non-JSON requests
  • Existing valid requests still work

Skills You'll Learn

  • API input validation
  • Defensive programming
  • Flask request handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    FOSSHack 2026FOSSHack 2026 HackathonbackendFlask backend issuesbugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions