Skip to content

structaccess: two ForceSendFields fixes in Set - #6466

Draft
denik wants to merge 2 commits into
mainfrom
denik/structaccess-forcesendfields
Draft

structaccess: two ForceSendFields fixes in Set#6466
denik wants to merge 2 commits into
mainfrom
denik/structaccess-forcesendfields

Conversation

@denik

@denik denik commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Two independent bugs in Set:

  • ForceSendFields was updated before the assignment, so a value that could not be converted left the field's send-behaviour changed even though the Set failed. Setting an omitempty numeric field to "" recorded it as force-send and then failed.
  • Emptiness was judged from the caller's value, not the converted one, so an omitempty number set from the string "0" was stored as zero and left out of ForceSendFields — marshalled as absent. Latent today, since no value library writes a number as a quoted string.

Both tests fail without the fix.

This pull request and its description were written by Isaac.

Set updated ForceSendFields before assigning, so a value that could not be converted left
the field's send-behaviour changed even though the Set failed: setting an omitempty numeric
field to "" recorded the field as force-send and then failed the conversion. The assignment
goes first.

Co-authored-by: Isaac
Set converted the caller's value on the way in but judged emptiness from the value it was
handed, so an omitempty numeric or bool field set from a string that converts to zero was
stored as zero and then left out of ForceSendFields -- and marshalled as absent. Setting
max_concurrent_runs to "0" silently meant unset.

Latent today, since no value library writes a number as a quoted string, but it contradicts
the contract callers rely on: a scalar is left to structaccess to convert between the numeric
and string kinds.

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant