Skip to content

Commit 1d9a0b9

Browse files
Scope Waterline health snapshots to the configured namespace
Expose the configured namespace in Waterline health responses. Reuse normalized namespace handling for both compatibility and native namespace-scoped workflow health snapshots.
1 parent dd4ccfd commit 1d9a0b9

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

app/Http/Controllers/V2HealthController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ class V2HealthController extends Controller
1212
public function show()
1313
{
1414
$engineSource = WorkflowEngineSourceResolver::status();
15+
$namespace = $this->namespace();
1516

1617
if (($engineSource['uses_v2'] ?? false) !== true) {
1718
return response()->json([
19+
'namespace' => $namespace,
1820
'generated_at' => now()->toJSON(),
1921
'status' => 'error',
2022
'healthy' => false,
@@ -50,6 +52,7 @@ public function show()
5052
'issue_count' => count(is_array($engineSource['issues'] ?? null) ? $engineSource['issues'] : []),
5153
],
5254
]);
55+
$snapshot['namespace'] = $namespace;
5356
$snapshot['engine_source'] = $engineSource;
5457
$snapshot['readiness_contract'] = $engineSource['readiness_contract'] ?? null;
5558

@@ -64,7 +67,7 @@ public function show()
6467
*/
6568
private function snapshotForConfiguredNamespace(): array
6669
{
67-
$namespace = config('waterline.namespace');
70+
$namespace = $this->namespace();
6871
$now = now();
6972

7073
if ((new \ReflectionMethod(HealthCheck::class, 'snapshot'))->getNumberOfParameters() >= 2) {
@@ -110,4 +113,11 @@ private static function invokeLegacyHealthCheck(string $method, mixed ...$args):
110113
HealthCheck::class,
111114
)($method, $args);
112115
}
116+
117+
private function namespace(): ?string
118+
{
119+
$namespace = config('waterline.namespace');
120+
121+
return is_string($namespace) && trim($namespace) !== '' ? trim($namespace) : null;
122+
}
113123
}

tests/Feature/V2HealthControllerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function testHealthEndpointReturnsV2HealthSnapshot(): void
3434

3535
$this->get('/waterline/api/v2/health')
3636
->assertStatus(200)
37+
->assertJsonPath('namespace', null)
3738
->assertJsonPath('status', 'ok')
3839
->assertJsonPath('healthy', true)
3940
->assertJsonPath('checks.0.name', 'engine_source')
@@ -63,6 +64,7 @@ public function testHealthEndpointScopesSnapshotToConfiguredNamespace(): void
6364

6465
$this->get('/waterline/api/v2/health')
6566
->assertStatus(200)
67+
->assertJsonPath('namespace', 'billing')
6668
->assertJsonPath('status', 'ok')
6769
->assertJsonPath('operator_metrics.runs.total', 1)
6870
->assertJsonPath('operator_metrics.tasks.ready_due', 1)

0 commit comments

Comments
 (0)