fix(query_builder): don't explode plucked scalars on masked doctypes (v16.12.2 hotfix)#2
Open
spc-agent-00 wants to merge 3 commits into
Open
fix(query_builder): don't explode plucked scalars on masked doctypes (v16.12.2 hotfix)#2spc-agent-00 wants to merge 3 commits into
spc-agent-00 wants to merge 3 commits into
Conversation
`execute_query` runs `mask_fields()` on every result whenever the queried
doctype has masked fields for the current (non-admin) user. With `pluck=True`
the DB layer has already reduced each row to a scalar, so the result is a flat
list of values rather than rows. `mask_list_results` then ran `list(row)` on
each scalar, turning "P-1156" into `('P', '-', '1', '1', '5', '6')` for strings
and raising `TypeError: 'int' object is not iterable` for numeric fields.
Handle `pluck` explicitly: mask each scalar only when the plucked field is
itself a masked field, otherwise return the value untouched. Admin users were
never affected since `get_masked_fields()` returns nothing for them.
Fixes frappe#39898
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address review feedback on frappe#39898: annotate the helper's arguments and return type, matching the style of mask_fields(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
DatabaseQuery.execute returned the plucked scalar list before running mask_fields, so a masked field leaked its raw value for non-admin users when callers asked for a flat pluck list. Mask the dict rows first, then pluck, reusing the existing mask_dict_results path. This is the legacy db_query counterpart to the query-builder pluck fix in #1. No core caller routes pluck through this engine on 16.12.2 (get_list/get_all/reportview use qb_query), so this covers direct DatabaseQuery callers and any code still on the legacy path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Backports the masked-fields
pluckfix from #1 onto a hotfix branch cut from thev16.12.2tag.Why
execute_queryrunsmask_fields()on every result when the queried doctype has masked fields for the current (non-admin) user. Withpluck=Truethe DB layer returns a flat list of scalars, butmask_list_resultsranlist(row)on each scalar — turning"P-1156"into('P','-','1','1','5','6')and raisingTypeError: 'int' object is not iterablefor numeric fields.What
pluckexplicitly: mask each scalar only when the plucked field is itself a masked field, otherwise return the value untouched.mask_pluck_resultshelper.Commits (cherry-picked from #1)
fix(query_builder): don't explode plucked scalars on masked doctypesfix(query_builder): add type hints to mask_pluck_results argsThe base branch
v16.12.2was created from thev16.12.2tag.🤖 Generated with Claude Code