Repository: rq/rq
Issue category: Bug Report

Issue:
Dangling job occurs when job_id contains the character ":"
Hi,

After updating to v2.0.0, job_id cannot contain the character ":"; otherwise, the job is never picked up or started by a worker.

I'll investigate this over the next few days, but I suspect that [PR #1964](https://github.com/rq/rq/pull/1964) might restrict the job_id format. We may need to add validation when creating jobs to address this.



Hints:
Thanks, mind opening a PR when you're free?

Patch:
diff --git a/rq/job.py b/rq/job.py
index 918f7fdc1..7a964aef0 100644
--- a/rq/job.py
+++ b/rq/job.py
@@ -729,6 +729,10 @@ def set_id(self, value: str) -> None:
         """
         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):


Test patch:
diff --git a/tests/test_job.py b/tests/test_job.py
index 36c356e50..9f93cfbf8 100644
--- a/tests/test_job.py
+++ b/tests/test_job.py
@@ -900,6 +900,13 @@ def test_create_job_with_id(self):
 
         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)