Skip to content

fix(communities): return 400 on malformed community id#2352

Open
slint wants to merge 1 commit into
inveniosoftware:masterfrom
slint:fix-comm-schema
Open

fix(communities): return 400 on malformed community id#2352
slint wants to merge 1 commit into
inveniosoftware:masterfrom
slint:fix-comm-schema

Conversation

@slint

@slint slint commented Jun 4, 2026

Copy link
Copy Markdown
Member
  • A non-string id (e.g. {}) failed nested field validation, but the
    uniqueness check ran via @validates("communities") on the partially
    loaded list and crashed with KeyError: 'id', returning a 500.
    marshmallow runs @validates field validators unconditionally, even on
    items that failed deserialization. Moved the count and uniqueness checks
    to a field validate=[...] callable, which runs only after every item
    deserialized, so a malformed entry surfaces as the nested 400 instead.

* A non-string `id` (e.g. `{}`) failed nested field validation, but the
  uniqueness check ran via `@validates("communities")` on the partially
  loaded list and crashed with `KeyError: 'id'`, returning a 500.
  marshmallow runs `@validates` field validators unconditionally, even on
  items that failed deserialization. Moved the count and uniqueness checks
  to a field `validate=[...]` callable, which runs only after every item
  deserialized, so a malformed entry surfaces as the nested 400 instead.
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