Skip to content

fix: mutate the same variable in place #369

Open
wreckage0907 wants to merge 3 commits into
version-16-hotfixfrom
fix/issue-2711
Open

fix: mutate the same variable in place #369
wreckage0907 wants to merge 3 commits into
version-16-hotfixfrom
fix/issue-2711

Conversation

@wreckage0907
Copy link
Copy Markdown

@wreckage0907 wreckage0907 commented Mar 25, 2026

Description

  • Updated the logic to handle Select field 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

  • I have carefully reviewed the code before submitting it for review.
  • This code is adequately covered by unit tests to validate its functionality.
  • I have conducted thorough testing to ensure it functions as intended.
  • A member of the QA team has reviewed and tested this PR (To be checked by QA or code reviewer)

Fixes #2711, #2712

@wreckage0907 wreckage0907 marked this pull request as ready for review March 26, 2026 06:38
@wreckage0907 wreckage0907 requested review from Aryan20 and Copilot March 26, 2026 06:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.options when formatting Select options for UI output by using a local options variable.
  • Expand Select option 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.

Comment thread next_crm/ncrm/doctype/crm_fields_layout/crm_fields_layout.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants