Commit 6360b56b authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

wire up productInfoError to fall back to 'kde' product

when a product fails to resolve in bugzilla we'll want to fall back on
the generic 'kde' product so the user can still conveniently report the
bug and get it triaged.

this most notably deals with scenarios where a kaboutdata product/binary
does not have its own bugzilla product and also has no mapping data in
our file (e.g. kdeinit5 is part of the frameworks-kinit product, without
mapping data we'll not able to file it there and the submission fails)

when product mapping now fails it will signal an error, the error is
connected to the fallback logic, which simply switches the product to
'kde' and retries the resolution

there's also a hint about why this bug was filed against 'kde' being
added to the report summary so people don't get confused and also to
perhaps prompt them to fix the mappings file
parent c3f6cd23
/*******************************************************************
* productmapping.cpp
* SPDX-FileCopyrightText: 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
* SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
......@@ -34,6 +35,8 @@ ProductMapping::ProductMapping(const CrashedApplication *crashedApp, BugzillaMan
// Get valid versions
connect(m_bugzillaManagerPtr, &BugzillaManager::productInfoFetched, this, &ProductMapping::checkProductInfo);
// Holding the connection so we can easily disconnect in the fallback logic.
m_productInfoErrorConnection = connect(m_bugzillaManagerPtr, &BugzillaManager::productInfoError, this, &ProductMapping::fallBackToKDE);
m_bugzillaManagerPtr->fetchProductInfo(m_bugzillaProduct);
}
......@@ -156,6 +159,20 @@ void ProductMapping::checkProductInfo(const Bugzilla::Product::Ptr product)
m_bugzillaVersionDisabled = inactiveVersions.contains(m_bugzillaVersionString);
}
void ProductMapping::fallBackToKDE()
{
// Fall back to the generic kde product when we couldn't find an explicit mapping.
// This is in an effort to make it as easy as possible to file a bug, unfortunately it means someone will
// have to triage it accordingly.
// Disconnect to safe-guard against infinite loop should kde also fail for some reason....
// An argument could be made that we should raise a user error if this fails again,
// 'kde' not resolving shouldn't ever happen and points at a huge problem somewhere.
disconnect(m_productInfoErrorConnection);
m_bugzillaProductOriginal = m_bugzillaProduct;
m_bugzillaProduct = QStringLiteral("kde");
m_bugzillaManagerPtr->fetchProductInfo(m_bugzillaProduct);
}
QStringList ProductMapping::relatedBugzillaProducts() const
{
return m_relatedBugzillaProducts;
......@@ -185,3 +202,8 @@ bool ProductMapping::bugzillaVersionDisabled() const
{
return m_bugzillaVersionDisabled;
}
QString ProductMapping::bugzillaProductOriginal() const
{
return m_bugzillaProductOriginal;
}
/*******************************************************************
* productmapping.h
* SPDX-FileCopyrightText: 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
* SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
......@@ -29,6 +30,8 @@ public:
explicit ProductMapping(const CrashedApplication *, BugzillaManager *, QObject *parent = nullptr);
QString bugzillaProduct() const;
// If bugzillaProduct is a fallback product, then this is non-empty original product string we tried to find.
QString bugzillaProductOriginal() const;
QString bugzillaComponent() const;
QString bugzillaVersion() const;
QStringList relatedBugzillaProducts() const;
......@@ -38,6 +41,8 @@ public:
private Q_SLOTS:
void checkProductInfo(const Bugzilla::Product::Ptr);
// Fall back to generic product because the product failed to resolve.
void fallBackToKDE();
private:
void map(const QString &);
......@@ -46,6 +51,7 @@ private:
QStringList m_relatedBugzillaProducts;
QString m_bugzillaProduct;
QString m_bugzillaProductOriginal;
QString m_bugzillaComponent;
QString m_bugzillaVersionString;
......@@ -55,6 +61,8 @@ private:
bool m_bugzillaProductDisabled;
bool m_bugzillaVersionDisabled;
QMetaObject::Connection m_productInfoErrorConnection;
};
#endif
......@@ -2,6 +2,7 @@
* reportinterface.cpp
* SPDX-FileCopyrightText: 2009, 2010, 2011 Dario Andres Rodriguez <andresbajotierra@gmail.com>
* SPDX-FileCopyrightText: 2009 George Kiagiadakis <gkiagia@users.sourceforge.net>
* SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
......@@ -239,9 +240,18 @@ QString ReportInterface::generateReportFullText(DrKonqiStamp stamp, Backtrace in
}
switch (stamp) {
case DrKonqiStamp::Include:
case DrKonqiStamp::Include: {
report.append(QLatin1String("\nReported using DrKonqi"));
const QString product = m_productMapping->bugzillaProduct();
const QString originalProduct = m_productMapping->bugzillaProductOriginal();
if (!originalProduct.isEmpty()) {
report.append(
QStringLiteral(
"\nThis report was filed against '%1' because the product '%2' could not be located in Bugzilla. Add it to drkonqi's mappings file!")
.arg(product, originalProduct));
}
break;
}
case DrKonqiStamp::Exclude:
break;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment