fix: mutate the same variable in place #369
Open
wreckage0907 wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a Next CRM issue where generating field layouts for UI could mutate shared Frappe DocField metadata (field.options) in-place, which becomes problematic with Frappe v16’s persistent meta cache.
Changes:
- Stop mutating
field.optionswhen formattingSelectoptions for UI output by using a localoptionsvariable. - Expand
Selectoption normalization to support strings (newline-separated), lists/tuples, or single values before converting to{label, value}objects.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Updated the logic to handle
Selectfield options by supporting options provided as a string (split by newline), list, tuple, or a single value, ensuring consistent formatting and preventing errors from unexpected types. (next_crm/ncrm/doctype/crm_fields_layout/crm_fields_layout.py, next_crm/ncrm/doctype/crm_fields_layout/crm_fields_layout.pyL39-R55)A latent Next CRM bug was mutating shared Frappe DocField metadata (field.options) from string to list during Address quick-entry layout generation, which v16’s persistent meta cache made reproducible at insert time (unhashable list), and we fixed it by using a local options variable for UI formatting without mutating metadata.
Relevant Technical Choices
Testing Instructions
Additional Information:
Screenshot/Screencast
Before:
Screen.Recording.2026-03-26.at.12.05.53.PM.mov
After:
Screen.Recording.2026-03-26.at.12.04.02.PM.mov
Checklist
Fixes #2711, #2712