ECDSA signature with r value of 31?

occasionally on Android we are generating an ECDSA signature. This turns out to have a “r” length of 31 bytes. Is that valid?

For reference here is a nice diagram outlining the ASN.1 structure of such a signature:

how do you figure out the r and s out of a signature using python

Best regards, Rene