Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't send minidumps if the endpoint isn't configured #1580

Merged
merged 3 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/electron/src/config/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ module.exports.schema = {
(val && typeof val === 'object') &&
(
// notify and sessions must always be set
// minidumps isn't required because it was added after the initial launch
// so would be a breaking change
stringWithLength(val.notify) && stringWithLength(val.sessions)
) &&
// ensure no keys other than notify/session/minidumps are set on endpoints object
Expand Down
6 changes: 6 additions & 0 deletions packages/electron/src/config/test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ describe('main process client config schema', () => {
notify: 'http://fakeurl.xyz/n',
sessions: 'http://fakeurl.xyz/s'
})).toBe(true)

expect(schema.endpoints.validate({
notify: 'http://fakeurl.xyz/n',
sessions: 'http://fakeurl.xyz/s',
minidumps: 'http://fakeurl.xyz/m'
})).toBe(true)
})

it('rejects invalid values', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/electron/types/notifier.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface MainConfig extends Config {
endpoints?: {
notify: string
sessions: string
minidumps?: string
}
onSendError?: OnSendErrorCallback | OnSendErrorCallback[]
onUncaughtException?: AfterErrorCallback
Expand Down
10 changes: 10 additions & 0 deletions packages/plugin-electron-deliver-minidumps/deliver-minidumps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ module.exports = (app, net, filestore, NativeClient) => ({
return
}

// the minidumps endpoint can only be missing for on-premise users who
// haven't configured it as it's not required by the config validation
if (typeof client._config.endpoints.minidumps !== 'string') {
client._logger.warn(
`Invalid configuration. endpoint.minidumps should be a valid URL, got ${typeof client._config.endpoints.minidumps}. Bugsnag will not send minidumps.`
)

return
}

const appRunMetadata = filestore.getAppRunMetadata()

// make sure that the Electron CrashReporter is configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,26 @@ describe('electron-minidump-delivery: load', () => {
enabledErrorTypes: {
nativeCrashes: true
},
endpoints: {
notify: 'notify.bugsnag.com',
sessions: 'sessions.bugsnag.com',
minidumps: 'notify.bugsnag.com'
},
maxBreadcrumbs: 16
},
_logger: {
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn()
}
}

plugin.load(client)

expect(nativeClient.install).toBeCalledTimes(1)
expect(whenReadyCallback).toBeInstanceOf(Function)
expect(client._logger.warn).not.toBeCalled()
})

it('should not install when autoDetectErrors disabled', () => {
Expand All @@ -54,14 +66,26 @@ describe('electron-minidump-delivery: load', () => {
enabledErrorTypes: {
nativeCrashes: true
},
endpoints: {
notify: 'notify.bugsnag.com',
sessions: 'sessions.bugsnag.com',
minidumps: 'notify.bugsnag.com'
},
maxBreadcrumbs: 16
},
_logger: {
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn()
}
}

plugin.load(client)

expect(nativeClient.install).not.toBeCalled()
expect(whenReadyCallback).toBeUndefined()
expect(client._logger.warn).not.toBeCalled()
})

it('should not install when nativeCrashes disabled', () => {
Expand All @@ -71,13 +95,55 @@ describe('electron-minidump-delivery: load', () => {
enabledErrorTypes: {
nativeCrashes: false
},
endpoints: {
notify: 'notify.bugsnag.com',
sessions: 'sessions.bugsnag.com',
minidumps: 'notify.bugsnag.com'
},
maxBreadcrumbs: 16
},
_logger: {
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn()
}
}

plugin.load(client)

expect(nativeClient.install).not.toBeCalled()
expect(client._logger.warn).not.toBeCalled()
})

it('should not install when the minidumps endpoint is not configured', () => {
const client = {
_config: {
autoDetectErrors: true,
enabledErrorTypes: {
nativeCrashes: true
},
endpoints: {
notify: 'notify.bugsnag.com',
sessions: 'sessions.bugsnag.com'
},
maxBreadcrumbs: 16
},
_logger: {
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn()
}
}

plugin.load(client)

expect(nativeClient.install).not.toBeCalled()
expect(whenReadyCallback).toBeUndefined()
expect(client._logger.warn).toHaveBeenCalledTimes(1)
expect(client._logger.warn).toHaveBeenCalledWith(
'Invalid configuration. endpoint.minidumps should be a valid URL, got undefined. Bugsnag will not send minidumps.'
)
})
})