fix uniweb-issue-1353: attempt to remove missing item from list#439
Conversation
Reviewer's Guide by SourceryThis pull request fixes issue #430 by changing the way readonly fields are determined. Instead of always attempting to remove "slug" and "overwrite_url" from the list of fields, the code now checks if these fields exist in the list before attempting to remove them. This prevents an error when trying to remove a non-existent item. Sequence diagram for readonly fields determinationsequenceDiagram
participant Admin as Admin System
participant Fields as Fields Handler
Admin->>Fields: get_readonly_fields(request, obj)
Note over Fields: Check if form has fieldsets
alt Has fieldsets
Fields->>Fields: flatten_fieldsets()
end
Fields->>Fields: Convert to list
Fields->>Fields: Find intersection with {slug, overwrite_url}
Fields->>Fields: Remove matching fields
Fields-->>Admin: Return filtered fields
State diagram for field removal logic changestateDiagram-v2
[*] --> CheckFields
CheckFields --> IntersectFields: Fields exist
IntersectFields --> RemoveFields: Matching fields found
RemoveFields --> [*]: Fields removed
IntersectFields --> [*]: No matching fields
note right of IntersectFields
New: Only attempt removal
of existing fields using
set intersection
end note
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @jrief - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please add tests to verify this fix - specifically a test case that would have caught the original KeyError and verifies the new behavior works correctly.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #439 +/- ##
=======================================
Coverage 91.21% 91.21%
=======================================
Files 72 72
Lines 2663 2663
Branches 307 307
=======================================
Hits 2429 2429
Misses 163 163
Partials 71 71 ☔ View full report in Codecov by Sentry. |
|
@jrief Thanks for the fix!! |
Description
Fix #430: sometimes fields are missing in list
Related resources
Checklist
masterSlack to find a “pr review buddy” who is going to review my pull request.
Summary by Sourcery
Bug Fixes: