scrapinghub / spidermon

Scrapy Extension for monitoring spiders execution.
https://spidermon.readthedocs.io
BSD 3-Clause "New" or "Revised" License
530 stars 96 forks source link

Error when using custom job tags action class #403

Closed vu3jej closed 1 year ago

vu3jej commented 1 year ago

I am trying to add tags using custom action classes by following the example here https://spidermon.readthedocs.io/en/latest/actions/job-tags-action.html#spidermon-job-tags-to-remove

I am getting the following error on scrapy:2.9 stack on Scrapy Cloud

[quotes] [Spidermon] Less

======================================================================
ERROR: AddJobTagsPassed
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/spidermon/core/[actions.py](http://actions.py/)", line 39, in run
    [self.run](http://self.run/)_action()
  File "/usr/local/lib/python3.10/site-packages/spidermon/contrib/actions/jobs/[tags.py](http://tags.py/)", line 26, in run_action
    self.process_tags(job_metadata)
  File "/usr/local/lib/python3.10/site-packages/spidermon/contrib/actions/jobs/[tags.py](http://tags.py/)", line 38, in process_tags
    if tag not in job_metadata["tags"]:
TypeError: 'JobMeta' object is not subscriptable

Spidermon version:

spidermon==1.18.0
VMRuiz commented 1 year ago

These actions uses the JobMeta class from Python-Scrapinghub package to update the tag information from jobs run in Scrapy Cloud.

At some point its interface must have been changed to onlly allow using get and set methods to read and write job's metadata. I will release a fix for this.