Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio fields that cannot be correctly parsed should report on the failing field #93

Open
gaurav opened this issue Feb 6, 2025 · 0 comments

Comments

@gaurav
Copy link

gaurav commented Feb 6, 2025

I ran into a problem with the VLMD tool recently: some fields in the input REDCap file didn't have a "Choices, Calculations, OR Slider Labels" value (because they had been redacted). This resulted in an exception being thrown by the _parse_field_properties_from_encodings() method called from mapradio():

def mapradio(field):
"""
RADIO - radio buttons with options
Determined by "options" (ie Choices, Calculations, OR Slider Labels)
"""
# parse enum/encodings
encodings_string = field[choices_fieldname]
return _parse_field_properties_from_encodings(encodings_string)

To help figure out where the error in the input was, it would be helpful if this exception was caught so that the field name was reported, or even a check for the most common error case (an empty field):

    if not encodings_string:
        raise ValueError(f"Empty encodings string not allowed in radio field {field} with column {choices_fieldname}.")

(The same is also true of dropdown fields, see below.)

def mapdropdown(field):
"""
DROPDOWN
dropdown menu with options
Determined by "options" (ie Choices, Calculations, OR Slider Labels)
"""
encodings_string = field[choices_fieldname]
return _parse_field_properties_from_encodings(encodings_string)

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

No branches or pull requests

1 participant