Skip to content

Commit

Permalink
cli: disable raven if not running from package
Browse files Browse the repository at this point in the history
In order to avoid bogus environment misconfiguration reports, only allow
Sentry submissions if running from the packaged distribution.

Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
  • Loading branch information
cmatsuoka committed Mar 15, 2019
1 parent 636d6be commit b484779
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion snapcraft/cli/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import snapcraft
from snapcraft.config import CLIConfig as _CLIConfig
from snapcraft.internal import errors
from snapcraft.internal.common import is_snap
from snapcraft.internal.build_providers.errors import ProviderExecError

# raven is not available on 16.04
Expand Down Expand Up @@ -113,7 +114,7 @@ def exception_handler( # noqa: C901
is_snapcraft_reportable_error = issubclass(
exception_type, errors.SnapcraftReportableError
)
is_raven_setup = RavenClient is not None
is_raven_setup = RavenClient is not None if is_snap() else False
is_connected_to_tty = (
# used by inner instance, variable set by outer instance
(distutils.util.strtobool(os.getenv("SNAPCRAFT_HAS_TTY", "n")) == 1)
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/cli/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import snapcraft.internal.errors
from snapcraft.internal.build_providers.errors import ProviderExecError
from snapcraft.cli._errors import exception_handler
from tests import unit
from tests import fixture_setup, unit


class TestSnapcraftError(snapcraft.internal.errors.SnapcraftError):
Expand All @@ -47,6 +47,8 @@ class ErrorsBaseTestCase(unit.TestCase):
def setUp(self):
super().setUp()

self.useFixture(fixture_setup.FakeSnapcraftIsASnap())

patcher = mock.patch("sys.exit")
self.exit_mock = patcher.start()
self.addCleanup(patcher.stop)
Expand Down

0 comments on commit b484779

Please sign in to comment.