Skip to content

fix(core): Return HTTP 400 for YAML parsing errors#20

Draft
sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/yaml-parsing-error-400
Draft

fix(core): Return HTTP 400 for YAML parsing errors#20
sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/yaml-parsing-error-400

Conversation

@sentry

@sentry sentry Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor

Previously, when a user submitted malformed YAML content to the optimization endpoint, a ruamel.yaml.YAMLError would be raised during data loading. This error was not specifically handled, causing it to fall through to the generic exception handler. As a result, the API would return an HTTP 500 Internal Server Error and log an error-level event in Sentry, misclassifying a client-side input issue as a server problem.

This change introduces a specific except YAMLError clause in core/nurse_scheduling/serve.py. Now, when a YAMLError occurs, the API will:

  • Log a warning message instead of an error.
  • Return an HTTP 400 Bad Request response, correctly indicating that the client's input was invalid.

This improves error handling and provides clearer feedback to users for invalid YAML submissions.

Fixes NURSE-SCHEDULING-W

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

Successfully merging this pull request may close these issues.

0 participants