mirror of https://github.com/rq/rq.git
Adds validation to avoid ":" when user pass job_id (#2138)
This commit is contained in:
parent
bb7f340537
commit
b44ae85a8d
|
@ -729,6 +729,10 @@ class Job:
|
|||
"""
|
||||
if not isinstance(value, str):
|
||||
raise TypeError('id must be a string, not {0}'.format(type(value)))
|
||||
|
||||
if ":" in value:
|
||||
raise ValueError('id must not contain ":"')
|
||||
|
||||
self._id = value
|
||||
|
||||
def heartbeat(self, timestamp: datetime, ttl: int, pipeline: Optional['Pipeline'] = None, xx: bool = False):
|
||||
|
|
|
@ -900,6 +900,13 @@ class TestJob(RQTestCase):
|
|||
|
||||
self.assertRaises(TypeError, queue.enqueue, fixtures.say_hello, job_id=1234)
|
||||
|
||||
def test_create_job_with_invalid_id(self):
|
||||
"""test creating jobs with a custom invalid ID (with character :)"""
|
||||
queue = Queue(connection=self.connection)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
queue.enqueue(fixtures.say_hello, job_id="1234:4321")
|
||||
|
||||
def test_create_job_with_async(self):
|
||||
"""test creating jobs with async function"""
|
||||
queue = Queue(connection=self.connection)
|
||||
|
|
Loading…
Reference in New Issue