Rude to ask what their preferred pronouns is?

Went for a walk with my babies, my daughter dropped something and this kind person picked it up and gave it to her. I told my daughter “say thank you to her”.

I felt bad that I assumed that this person was a “her”… could have been a “he”, “they”, or non binary.

This person looked like a female, had b**bs and all, but she was dressed in men’s outfit/shoes, and had masculine haircut

It was AFTER this person left, that I thought about what I said.

My question now is, when not sure about the person’s preferred pronouns, is it rude to ask? Or do we just assume? How do I address a stranger that i am not sure of their pronouns?

I would like to know this, so as not to offend anyone in the future. I still feel bad that I address this person as a “she” and that was probably not her preferred pronouns.