Skip to content

fix: log HTTP 400 causes and handle malformed JSON - #152

Open
andig wants to merge 3 commits into
mainfrom
fix/http-error-reporting
Open

andig wants to merge 3 commits into
mainfrom
fix/http-error-reporting

Conversation

@andig

@andig andig commented Sep 5, 2026

Copy link
Copy Markdown
Member

Found during Azure KPI checks for #151.

Malformed JSON currently raises an AttributeError in the custom BadRequest handler and returns HTTP 500. Return a JSON 400 response instead, and make ordinary 400 rejections diagnosable in Log Analytics.

  • Emit a structured bad_request event with the endpoint, cause category, first failing schema validator, and affected field names.
  • Exclude submitted values, exception values, authorization headers, and query strings from the diagnostic event.
  • Preserve explicit validation messages, including time-series length mismatches, instead of wrapping them in a generic error.

🤖 Generated with OpenCode

@andig
andig marked this pull request as ready for review September 5, 2026 16:53
andig added a commit that referenced this pull request Sep 5, 2026
Production rejects a steady eight to twelve requests an hour with "All time
series must have the same length" and the log could not say which series was
short, so the client bug behind it cannot be traced. The response and the log
now carry every series length. Values stay out of the log as before, a length
is shape, not content.

dt was not among the validated series. The model indexes every series by it,
so a short dt was an IndexError and a 500 instead of a 400 naming the series.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
evcc sends User-Agent evcc/<version> on every request. A rejected request
is usually a client bug, and the version names the release carrying it:
the empty solar forecast behind the length mismatches was fixed in evcc
0.309.0, which the log could not tell.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

1 participant