Skip to content
Open
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
12 changes: 10 additions & 2 deletions .github/workflows/postman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ name: API Contract (Postman)
# collection against the live API. Delegates to the reusable workflow in
# fleetbase/fleetbase. Requires org secrets POSTMAN_API_KEY + _GITHUB_AUTH_TOKEN
# (inherited); no-ops until POSTMAN_API_KEY is set.
# TODO: change @dev-v0.7.53 to @main once that branch is merged.
#
# Deliberately unpinned. The reusable workflow defaults to booting fleetbase/fleetbase@main
# against fleetbase/fleetbase-api:latest, so every release is picked up automatically and
# there is no ref here to remember to bump. Each run records the image digest it actually
# resolved in its job summary, so a result stays traceable. To reproduce an older run:
#
# with:
# fleetbase-ref: v0.7.53
# api-image: fleetbase/fleetbase-api:v0.7.53

on:
push:
Expand All @@ -18,7 +26,7 @@ permissions:

jobs:
contract:
uses: fleetbase/fleetbase/.github/workflows/api-contract.yml@dev-v0.7.53
uses: fleetbase/fleetbase/.github/workflows/api-contract.yml@main
with:
collections: "Fleetbase Core API"
build-from-source: false
Expand Down
19 changes: 17 additions & 2 deletions src/Http/Controllers/Internal/v1/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -906,26 +906,41 @@ protected function setTemporarySmsProviderConfig(string $provider, array $provid
*/
public function testSentryConfig(AdminRequest $request)
{
$dsn = $request->input('dsn');
$dsn = $request->input('dsn');
$clientDsn = $dsn;

// Set config from request
config(['sentry.dsn' => $dsn]);

if (is_string($dsn) && $dsn !== '') {
try {
$clientDsn = \Sentry\Dsn::createFromString($dsn);
} catch (\InvalidArgumentException) {
return response()->json([
'status' => 'error',
'message' => 'The provided Sentry DSN is invalid.',
]);
}
}

$message = 'Sentry configuration is successful, test Exception sent.';
$status = 'success';
$clientBuilder = null;

try {
$clientBuilder = \Sentry\ClientBuilder::create([
'dsn' => $dsn,
'dsn' => $clientDsn,
'release' => env('SENTRY_RELEASE'),
'environment' => app()->environment(),
'traces_sample_rate' => 1.0,
]);
// @codeCoverageIgnoreStart
// Sentry client construction errors depend on SDK versions that throw instead of normalizing invalid options.
} catch (\Exception $e) {
$message = $e->getMessage();
$status = 'error';
}
// @codeCoverageIgnoreEnd

if ($clientBuilder) {
// Set the Laravel SDK identifier and version
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Http/SettingControllerExternalProbesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function setting_controller_external_probe_request(array $input = []): AdminRequ
]);
});

test('test sentry config returns sdk builder errors for invalid dsns', function () {
test('test sentry config rejects invalid dsns before sdk fallback handling', function () {
setting_controller_external_probe_fixtures();

$response = (new SettingController())->testSentryConfig(setting_controller_external_probe_request([
Expand All @@ -192,7 +192,7 @@ function setting_controller_external_probe_request(array $input = []): AdminRequ
expect($response->getStatusCode())->toBe(200)
->and($response->getData(true))->toBe([
'status' => 'error',
'message' => 'The option "dsn" with value "not-a-dsn" is invalid.',
'message' => 'The provided Sentry DSN is invalid.',
])
->and(config('sentry.dsn'))->toBe('not-a-dsn');
});
Expand Down
Loading