Skip to content

Standardize API error response format in option_greeks.py #1022

@marketcalls

Description

@marketcalls

Description

The `option_greeks.py` endpoint returns validation errors in a different format than all other endpoints. This breaks API consistency.

Affected File

  • `restx_api/option_greeks.py` (lines 99-100)

Current Behavior

```python

option_greeks.py returns:

{"status": "error", "errors": err.messages}

e.g., {"status": "error", "errors": {"symbol": ["Missing data for required field."]}}

All other endpoints return:

{"status": "error", "message": "Human-readable error message"}
```

What to Do

Standardize to match the project convention:

```python

Before

except ValidationError as err:
return make_response(jsonify({
"status": "error",
"errors": err.messages
}), 400)

After

except ValidationError as err:
return make_response(jsonify({
"status": "error",
"message": "Validation error",
"errors": err.messages # Keep for details, but add "message" key
}), 400)
```

Acceptance Criteria

  • Response includes standard `"message"` key
  • Detailed validation errors preserved in `"errors"` key
  • Consistent with other endpoint error responses

Skills You'll Learn

  • API design consistency
  • Error response patterns (REST API best practices)
  • Flask-RESTX response formatting

Metadata

Metadata

Assignees

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