Skip to content

CatalogWarning duplicates hints when consumer wrappers supply catalog on rebuild #21

Description

@dprada

What — CatalogWarning duplicates a catalog hint when an integration class
passes its catalog and metadata on an args-only rebuild. This is the
constructor pattern shown in standards/SMONITOR_GUIDE.md §3.3.1.

How — With the current SMonitor checkout (0.16.0+4.gec50e9e), run:

import smonitor
from smonitor.integrations import CatalogWarning

smonitor.configure(
    profile="user",
    handlers=[],
    codes={"X-W1": {"user_message": "Original message.", "user_hint": "Suggested action."}},
)
catalog = {"warnings": {"ExampleWarning": {"code": "X-W1"}}}

class ExampleWarning(CatalogWarning):
    catalog_key = "ExampleWarning"

    def __init__(self, message=None):
        super().__init__(message, catalog=catalog, meta={})

warning = ExampleWarning()
rebuilt = type(warning)(*warning.args)
assert str(rebuilt) == str(warning)

The assertion fails: the original is Original message. Suggested action.;
the rebuild is Original message. Suggested action. Suggested action..
CatalogWarning.__init__ recognizes args-only rebuild text only when both
catalog and meta are absent. A consumer wrapper that supplies them on
every call prevents this recognition, so the already rendered text receives
the hint again.

Why — MolSysMT permits smonitor>=0.13.0. With this checkout, its
tests/_private suite has 15 failures and 788 passes under
pytest --receptor=llm -n 12: 14 warning round-trip cases and one
direct reconstruction test. The direct test also fails without xdist.
The affected warning text is visible to users and in test diagnostics.

Related: #4 fixed args-only handling for warnings whose
constructors do not supply catalog/metadata on rebuild; uibcdf/molsysmt#158
and uibcdf/molsysmt#161 are closed consumer guards that now fail again.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponent:molsysmtCross-component relationship with uibcdf/molsysmt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions