Skip to content

unclear error message in safe_setitem #10993

@d-v-b

Description

@d-v-b

What is your issue?

safe_setitem can raise a ValueError with the following message:

f"failed to prevent overwriting existing key {key} in attrs{var_str}. "
"This is probably an encoding field used by xarray to describe "
"how a variable is serialized. To proceed, remove this key from "
"the variable's attributes manually."

I found the first sentence very confusing, as "failed to do X" made me think we wanted to do X but failed, when in fact the opposite is true: we failed (raised an exception), in order to do X (avoid overwriting a protected attribute)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions