Delaying unlink or write on a model whose method was replaced raises AttributeError at enqueue time
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #998 来自 @akarazhev —— 已合并
评估
调研方向
Start by tracing the delayed-call method lookup and job serialization path described in the report, especially queue_job/job.py methods func, description, and _store_values. Reproduce the issue with the provided res.partner.unlink replacement and verify the behavior for both delayable() and with_delay(). Done means the job records and resolves the originally requested method name; an open linked pull request already addresses this issue.
由索引模型根据 Issue 内容生成。
描述
Module
queue_job (18.0.1.3.0).
Describe the bug
A delayed call (delayable() and with_delay()) is recorded by the __name__ of the function that the
attribute lookup happened to return, not by the name that was looked up
recordset_method = getattr(self.recordset, name)
self._job_method = recordset_method
This leads to:
File "queue_job/job.py", in _store_values
"name": self.description,
File "queue_job/job.py", in description
elif self.func.__doc__:
File "queue_job/job.py", in func
return getattr(recordset, self.method_name)
AttributeError: 'res.partner' object has no attribute 'unlink_renamed'
To Reproduce
Affected Versions:
Occured on 18.0 but code is unchanged on newer versions.
cls = type(env["res.partner"])
original = cls.unlink
def unlink_renamed(self):
return unlink_renamed.origin(self)
unlink_renamed.origin = original
cls.unlink = unlink_renamed
partner = env["res.partner"].create({"name": "test"})
partner.delayable().unlink().delay()
Expected behavior
The job records the method under the name it was requested with, and resolves
that name again, independent of what the attribute currently points at.
Additional context
Where this shows up in practice
auditlog (https://github.com/OCA/server-tools) installs its replacements as write_full and unlink_full into
the write and unlink slots, so any delayed write or unlink on an
audited model fails this way.
- 主要语言
- Python
- 星标
- 271
- 派生
- 602
- 平均合并
- 5 天 1 小时
- 30 天内合并 PR
- 7
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OCA/queue 的其他 Issue
-
enhancement
难度 3/5 1-2 天 新手友好度 30/100
维护者通常 1 天内回复
-
help wanted no stale work in progress
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
[19.0] queue_job: Jobs stay pending after the jobrunner's database connection is silently dropped可能已有人在做 @HoloborodkoBohdan 于 31 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 25/100
OCA/queue#984 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
OCA/queue#965 · 1 个 reaction ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
OCA/queue#964 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 86/100
awslabs/visual-asset-management-system#937 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
follow-up
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复