Skip to content

[19.0][FIX] mis_builder: don't report unresolvable styles on intermediate passes - #830

Open
MiquelRForgeFlow wants to merge 2 commits into
OCA:19.0from
ForgeFlow:19.0-fix-mis_builder-unresolvable-styles
Open

[19.0][FIX] mis_builder: don't report unresolvable styles on intermediate passes#830
MiquelRForgeFlow wants to merge 2 commits into
OCA:19.0from
ForgeFlow:19.0-fix-mis_builder-unresolvable-styles

Conversation

@MiquelRForgeFlow

@MiquelRForgeFlow MiquelRForgeFlow commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

KpiMatrix.set_values_detail_account is called on every pass of the computation loop, including the passes where a KPI is requeued because its expression referenced a KPI that was not evaluated yet. On those passes locals_dict is incomplete, so a style_expression referring to the KPI's own value fails and mis_safe_eval returns a DataError.

DataError subclasses Exception, so it is truthy and renders as an empty string. It was therefore passed to the style search and logged as Style '' not found. once per intermediate pass. That is noise on a perfectly correct report, and it hides the real problem when a style expression is actually broken:

    # a report whose KPI style expression references its own value, before
    ERROR ... kpimatrix: Style '' not found.
    ERROR ... kpimatrix: Style '' not found.
    ERROR ... kpimatrix: Style '' not found.

    # after
    (nothing)

    # a genuinely broken style expression, before
    ERROR ... kpimatrix: Style '' not found.

    # after
    ERROR ... kpimatrix: Error evaluating style expression
      <'Big' if unknown_kpi > 10 else 'Small'>: NameError: name 'unknown_kpi' is not defined

The style evaluation is now skipped when the cell value is itself in error, since that error is already reported in the cell, and a DataError coming from the style expression is reported with its actual message. style_name is also initialised, as it was left unbound if mis_safe_eval ever raised.

No preliminary issue was opened, as the change is small and self-contained.

Test

mis_builder/tests/test_style_expression.py is added in a separate commit (e6dd781) so the bug can be reproduced before the fix. On that commit the three tests fail:

    FAIL: TestStyleExpression.test_style_expression_of_requeued_kpi
    AssertionError: Unexpected logs found: ["ERROR:...kpimatrix:Style '' not found."]
    FAIL: TestStyleExpression.test_style_expression_error
    AssertionError: 2 != 1
    FAIL: TestStyleExpression.test_style_expression_not_found
    AssertionError: 2 != 1

With the fix applied the full module suite is green (122 tests, 0 failed).

Target branch

19.0, where the bug is. The "Target branch" section of the PR template is out of date: it still refers to versions 9 to 12 and asks to target 10.0.

CLA

Signed.

Changelog entry

mis_builder/readme/newsfragments/830.bugfix, included in the fix commit.

Cover the evaluation of the style_expression of a mis.report.kpi: the style of
a kpi requeued for recomputation, an expression that cannot be evaluated, and
one naming a style that does not exist.

The three tests fail on this commit.
@oca-cla-bot

oca-cla-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@OCA-git-bot

Copy link
Copy Markdown
Contributor

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

…asses

A requeued kpi is set in the matrix with an incomplete locals_dict, so its
style_expression fails and the resulting DataError, being truthy, was logged
as "Style '' not found." once per pass. Skip the evaluation when the cell
value is in error, and report a failing expression with its real message.
@MiquelRForgeFlow
MiquelRForgeFlow force-pushed the 19.0-fix-mis_builder-unresolvable-styles branch from e6f6c89 to 82e86d4 Compare September 10, 2026 16:47
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.

2 participants