Skip to content

feat: add ui parameter to all add_info functions#561

Merged
bdrung merged 1 commit intocanonical:mainfrom
bdrung:ui-parameter
Mar 30, 2026
Merged

feat: add ui parameter to all add_info functions#561
bdrung merged 1 commit intocanonical:mainfrom
bdrung:ui-parameter

Conversation

@bdrung
Copy link
Copy Markdown
Member

@bdrung bdrung commented Mar 24, 2026

_run_hook calls the add_info functions with two parameters and falls back to one parameter for backward compatibility. So add the second ui parameter to all add_info functions. This will make reading tracebacks easier (since the fallback will not be in the trace then).

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.42%. Comparing base (72f422b) to head (6bd5bc9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #561   +/-   ##
=======================================
  Coverage   84.42%   84.42%           
=======================================
  Files         104      104           
  Lines       20910    20910           
  Branches     3275     3275           
=======================================
  Hits        17653    17653           
- Misses       2817     2818    +1     
+ Partials      440      439    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdrung bdrung force-pushed the ui-parameter branch 2 times, most recently from 06798ee to 4f07f1d Compare March 25, 2026 17:42
`_run_hook` calls the `add_info` functions with two parameters and falls
back to one parameter for backward compatibility. So add the second `ui`
parameter to all `add_info` functions. This will make reading tracebacks
easier (since the fallback will not be in the trace then).

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
@bdrung bdrung requested a review from Hyask March 30, 2026 10:39
Copy link
Copy Markdown
Contributor

@Hyask Hyask left a comment

Choose a reason for hiding this comment

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

LGTM, but some additional context wouldn't hurt in the PR description in the form of a traceback before and after.

@bdrung
Copy link
Copy Markdown
Member Author

bdrung commented Mar 30, 2026

I don't remember where I saw it, but the relevant calling code is:

def _run_hook(report, ui, hook):
    if not os.path.exists(hook):
        return False

    symb = {}
    try:
        with open(hook, encoding="utf-8") as fd:
            # legacy, pylint: disable=exec-used
            exec(compile(fd.read(), hook, "exec"), symb)
        try:
            symb["add_info"](report, ui)
        except TypeError as error:
            if str(error).startswith("add_info()"):
                # older versions of apport did not pass UI, and hooks that
                # do not require it don't need to take it
                symb["add_info"](report)
            else:
                raise

@bdrung bdrung merged commit 6bd5bc9 into canonical:main Mar 30, 2026
20 checks passed
@bdrung bdrung deleted the ui-parameter branch March 30, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants