Skip to content

report: add support for YAQL expressions in bug patterns#485

Open
ogayot wants to merge 1 commit intocanonical:mainfrom
ogayot:with-yaql-bugpattern
Open

report: add support for YAQL expressions in bug patterns#485
ogayot wants to merge 1 commit intocanonical:mainfrom
ogayot:with-yaql-bugpattern

Conversation

@ogayot
Copy link
Member

@ogayot ogayot commented Mar 25, 2025

Bug patterns have historically only supported executing regular expressions. This is ok for log files and simple strings, but when we have access to more structured data (i.e., JSON or YAML) in bug reports, having the ability to find elements in such files is very useful.

In particular, this would be beneficial for Subiquity, where we have a large number of bug reports that we currently de-duplicate manually. We want to rely more on automation for such tasks.

In addition to regular expressions, we now support YAQL expressions [1] in bug patterns. They can be specified using the following syntax:

<pattern url="https://launchpad.net/bugs/XXX">
  <re key="package">subiquity</re>
  <yaql key="ProbeData">
      [ YAQL expression ]
  </yaql>
</pattern>

The format attribute can optionally be specified and will control the parser used. Supported values are "yaml" (the default) and "json".

The YAML parser can parse JSON but is slightly slower, thus specifying format="json" is recommended for JSON files.

Patterns having <yaql> tags will be considered non-matches if the yaql python module is not installed.

https://yaql.readthedocs.io/en/latest/getting_started.html

@ogayot ogayot force-pushed the with-yaql-bugpattern branch from 2b77dc4 to 2dd579d Compare March 25, 2025 12:01
@ogayot
Copy link
Member Author

ogayot commented Mar 25, 2025

I'll need to gracefully handle the absence of the yaml module as well.

@ogayot ogayot force-pushed the with-yaql-bugpattern branch from 2dd579d to b80a85e Compare March 25, 2025 12:15
@codecov
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

❌ Patch coverage is 70.00000% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.44%. Comparing base (3164b24) to head (e97565f).
⚠️ Report is 113 commits behind head on main.

Files with missing lines Patch % Lines
apport/report.py 46.77% 29 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #485      +/-   ##
==========================================
- Coverage   83.92%   82.44%   -1.48%     
==========================================
  Files         101       99       -2     
  Lines       20455    20474      +19     
  Branches     3215     3159      -56     
==========================================
- Hits        17167    16880     -287     
- Misses       2839     3114     +275     
- Partials      449      480      +31     

☔ 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.

Bug patterns have historically only supported executing regular expressions.
This is ok for log files and simple strings, but when we have access to more
structured data (i.e., JSON or YAML) in bug reports, having the ability to find
elements in such files is very useful.

In addition to regular expressions, we now support YAQL expressions in bug
patterns. They can be specified using the following syntax:

  <pattern url="https://launchpad.net/bugs/XXX">
    <re key="package">subiquity</re>
    <yaql key="ProbeData">
        [ YAQL expression ]
    </yaql>
  </pattern>

The format attribute can optionally be specified and will control the parser
used. Supported values are "yaml" (the default) and "json".

The YAML parser can parse JSON but is slightly slower, thus specifying
format="json" is recommended for JSON files.

Patterns having <yaql> tags will be considered non-matches if the yaql python
module is not installed.
@ogayot ogayot force-pushed the with-yaql-bugpattern branch from b80a85e to e97565f Compare March 25, 2025 13:42
@schopin-pro
Copy link
Contributor

@ogayot gentle ping on this, are you planning on coming back around to it?

@ogayot
Copy link
Member Author

ogayot commented May 28, 2025

@ogayot gentle ping on this, are you planning on coming back around to it?

I would like to, yes. Ideally sometime during the questing cycle.

Before I fix the tests though, I'd be happy to get some feedback on the general idea around this change. Is this something that sounds reasonable to have in apport upstream?

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