Skip to content

[18.0] [FIX] queue_job: fix exception msg handling#826

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
acsone:18.0-fix_exception_name_to_args0-bwi
Sep 18, 2025
Merged

[18.0] [FIX] queue_job: fix exception msg handling#826
OCA-git-bot merged 1 commit into
OCA:18.0from
acsone:18.0-fix_exception_name_to_args0-bwi

Conversation

@ThomasBinsfeld
Copy link
Copy Markdown
Contributor

Forward port of #824 (16.0)

17.0 PR : #825

'name' attributes for odoo's exception has been deprecated and produces a warning message. This commit fixes the behavior

@OCA-git-bot
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

@FrancoMaxime FrancoMaxime left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@AnizR AnizR left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@amh-mw amh-mw left a comment

Choose a reason for hiding this comment

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

Test coverage?

exception_name = orig_exception.__module__ + "." + exception_name
exc_message = getattr(orig_exception, "name", str(orig_exception))
exc_message = (
orig_exception.args[0] if orig_exception.args else str(orig_exception)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So I just noticed above

        except (FailedJobError, Exception) as orig_exception:

and both of those classes extend Exception, which extends BaseException, which is defined

class BaseException:
    args: tuple[Any, ...]

so I withdraw my comment about the args[0] guard. As penance, here is a unit test:

# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from odoo.tests import TransactionCase

from ..controllers.main import RunJobController
from ..job import Job


class TestRunJobController(TransactionCase):
    def test_get_failure_values(self):
        method = self.env["res.users"].mapped
        job = Job(method)
        ctrl = RunJobController()
        rslt = ctrl._get_failure_values(job, "info", Exception("zero", "one"))
        self.assertEqual(rslt, {
            "exc_info": "info",
            "exc_name": "Exception",
            "exc_message": "zero"
        })

@ThomasBinsfeld
Copy link
Copy Markdown
Contributor Author

The modified file doesn't seem covered at all, we won't write its coverage in this PR. I suggest to merge as it. ping @guewen

@amh-mw
Copy link
Copy Markdown
Member

amh-mw commented Sep 16, 2025

The modified file doesn't seem covered at all, we won't write its coverage in this PR. I suggest to merge as it. ping @guewen

Yes, that's why I offered unit test in prior comment.

'name' attributes for odoo's exception has been deprecated and produces a warning message. This commit fixes the behavior
@ThomasBinsfeld ThomasBinsfeld force-pushed the 18.0-fix_exception_name_to_args0-bwi branch from 77e4da3 to 9dc1766 Compare September 17, 2025 08:20
@ThomasBinsfeld
Copy link
Copy Markdown
Contributor Author

The modified file doesn't seem covered at all, we won't write its coverage in this PR. I suggest to merge as it. ping @guewen

Yes, that's why I offered unit test in prior comment.

Missed it, sorry. I've added it in the three PR's.

@guewen
Copy link
Copy Markdown
Member

guewen commented Sep 18, 2025

/ocabot merge patch
Thanks both for the code and the test :)

@OCA-git-bot
Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 18.0-ocabot-merge-pr-826-by-guewen-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 422b5f6 into OCA:18.0 Sep 18, 2025
7 checks passed
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at e416ded. Thanks a lot for contributing to OCA. ❤️

@sbidoul sbidoul deleted the 18.0-fix_exception_name_to_args0-bwi branch January 4, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants