Skip to content

[18.0][FIX] queue_job_cron_jobrunner: do not use deprecated tools.ustr() - #1038

Open
robsalasco wants to merge 1 commit into
OCA:18.0from
robsalasco:18.0-fix-queue_job_cron_jobrunner-ustr
Open

robsalasco wants to merge 1 commit into
OCA:18.0from
robsalasco:18.0-fix-queue_job_cron_jobrunner-ustr

Conversation

@robsalasco

Copy link
Copy Markdown

Problem

When a job raises a PostgreSQL concurrency error, queue.job._process() builds the postpone message with tools.ustr(err.pgerror, errors="replace"). ustr() is deprecated since Odoo 18 and emits a DeprecationWarning on every call, which shows up as a py.warnings WARNING in logs and test builds:

WARNING ... py.warnings: .../queue_job_cron_jobrunner/models/queue_job.py:72: DeprecationWarning: Deprecated since Odoo 18: ustr() is a garbage bag of weirdo fallbacks ...

Fix

Use str(err.pgerror) instead. Behavior is unchanged: psycopg2 exposes pgerror as a str (or None), and for those values ustr() only ever returned str(value). The now unused tools import is removed.

Tests

New test test_queue_job_process_concurrency_error: a job whose perform() raises a serialization failure is postponed by PG_RETRY seconds with the error text as result, and no DeprecationWarning is emitted from queue_job_cron_jobrunner/models/queue_job.py. This branch of _process() had no test coverage before.

-i queue_job_cron_jobrunner --test-tags /queue_job_cron_jobrunner:

  • Without the fix: 1 failed ... of 6 tests (the new test, with the ustr() warning).
  • With the fix: 0 failed, 0 error(s) of 6 tests, no WARNING/ERROR lines in the log.

The same tools.ustr call exists on 17.0 and 19.0; this can be forward-ported once merged.

tools.ustr() is deprecated since Odoo 18 and emits a DeprecationWarning on
every call. psycopg2 exposes pgerror as a str (or None), and for those
values ustr() only returned str(value), so use str() directly.

Add a test covering the PostgreSQL concurrency error branch of _process():
the job is postponed by PG_RETRY seconds with the error text as result,
without deprecation warnings.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @ivantodorovich,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:18.0 mod:queue_job_cron_jobrunner Module queue_job_cron_jobrunner labels Nov 24, 2026
Comment on lines +72 to +73
# pgerror is already a str (or None): tools.ustr() is
# deprecated since Odoo 18 and only called str() here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# pgerror is already a str (or None): tools.ustr() is
# deprecated since Odoo 18 and only called str() here.

this comment belongs to the commit message, not the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:queue_job_cron_jobrunner Module queue_job_cron_jobrunner series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants