Handle non-mapping request data in update_traits#7953
Conversation
|
@m-husnain-dev is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
for more information, see https://pre-commit.ci
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change adds a validation check to the Estimated code review effort: 1 (Trivial) | ~3 minutes Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant EdgeIdentityViewSet
participant TraitModel
Client->>EdgeIdentityViewSet: PUT/POST trait data
EdgeIdentityViewSet->>EdgeIdentityViewSet: check isinstance(request.data, dict)
alt is dict
EdgeIdentityViewSet->>TraitModel: construct trait instances
TraitModel-->>EdgeIdentityViewSet: validated traits
EdgeIdentityViewSet-->>Client: success response
else not dict
EdgeIdentityViewSet-->>Client: ValidationError
end
Related issues: None specified. Related PRs: None specified. Suggested labels: api, bug-fix Suggested reviewers: None specified. 🐰 A tiny check before the trait, Comment |
Description
This change prevents a crash when
request.datais not a mapping before unpacking it with**request.datainupdate_traits().Instead of raising a
TypeError, the endpoint now returns a properValidationErrorfor invalid request payloads.Fixes #7951