HugoPelletier commented on issue #11473: URL: https://github.com/apache/pulsar/issues/11473#issuecomment-889259292
There are 2 classes to modified to fix this issue. In both cases (Field and String), the method validate_type is ignoring the required keyword argument. **Field class** (https://github.com/apache/pulsar/blob/master/pulsar-client-cpp/python/pulsar/schema/definition.py#L148) ```python def validate_type(self, name, val): if not val and not self._required: return self.default() if type(val) != self.python_type(): raise TypeError("Invalid type '%s' for field '%s'. Expected: %s" % (type(val), name, self.python_type())) return val ``` **String class** (https://github.com/apache/pulsar/blob/master/pulsar-client-cpp/python/pulsar/schema/definition.py#L280) ```python def validate_type(self, name, val): t = type(val) if not val and not self._required: return self.default() if not (t is str or t.__name__ == 'unicode'): raise TypeError("Invalid type '%s' for field '%s'. Expected a string" % (t, name)) return val -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
