Incorrectly handling error path in the pipeline when handling arrays.
starrify opened this issue · 1 comments
starrify commented
Version being used: 2a1d434
Sample code to test with:
# coding: utf8
from scrapy_jsonschema import JsonSchemaItem, JsonSchemaValidatePipeline
class TestItem(JsonSchemaItem):
jsonschema = {
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
"properties": {
"test": {
"type": "array",
"items": {
"type": "string",
},
},
},
}
def test():
item = TestItem()
item['test'] = [1]
stats = type('', (), {})
stats.inc_value = lambda x: x
pipeline = JsonSchemaValidatePipeline(stats)
pipeline.process_item(item, None)
if __name__ == '__main__':
test()
Expected result: An exception DropItem
raised with message "schema validation failed: xxx"
.
Actual result:
Traceback (most recent call last):
File "test.py", line 32, in <module>
test()
File "test.py", line 27, in test
pipeline.process_item(item, None)
File "/home/pengyu/temp/virtualenv/lib/python2.7/site-packages/scrapy_jsonschema/pipeline.py", line 33, in process_item
path = '.'.join(absolute_path)
TypeError: sequence item 1: expected string, int found
VMRuiz commented
This issue is fixed in the last commit