Skip to content

Commit 60a1e60

Browse files
authored
Mariano/fix 12 (#1899)
* refactor(api): improve handling of required variables in connections and auto-check services
1 parent 00a835b commit 60a1e60

File tree

3 files changed

+49
-11
lines changed

3 files changed

+49
-11
lines changed

apps/api/src/integration-platform/controllers/connections.controller.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ export class ConnectionsController {
9191
const seenTaskIds = new Set<string>();
9292
const requiredVariables = new Set<string>();
9393

94+
// Collect manifest-level required variables
95+
for (const variable of m.variables || []) {
96+
if (variable.required) {
97+
requiredVariables.add(variable.id);
98+
}
99+
}
100+
101+
// Collect check-level required variables
94102
for (const check of m.checks || []) {
95103
if (check.taskMapping && !seenTaskIds.has(check.taskMapping)) {
96104
seenTaskIds.add(check.taskMapping);
@@ -100,7 +108,6 @@ export class ConnectionsController {
100108
mappedTasks.push({ id: check.taskMapping, name: taskInfo.name });
101109
}
102110
}
103-
// Collect required variables
104111
if (check.variables) {
105112
for (const variable of check.variables) {
106113
if (variable.required) {
@@ -158,8 +165,17 @@ export class ConnectionsController {
158165
const mappedTasks: Array<{ id: string; name: string }> = [];
159166
const seenTaskIds = new Set<string>();
160167

161-
// Collect required variables from all checks
168+
// Collect required variables (manifest-level and check-level)
162169
const requiredVariables = new Set<string>();
170+
171+
// Manifest-level variables
172+
for (const variable of manifest.variables || []) {
173+
if (variable.required) {
174+
requiredVariables.add(variable.id);
175+
}
176+
}
177+
178+
// Check-level variables
163179
for (const check of manifest.checks || []) {
164180
if (check.taskMapping && !seenTaskIds.has(check.taskMapping)) {
165181
seenTaskIds.add(check.taskMapping);
@@ -169,7 +185,6 @@ export class ConnectionsController {
169185
mappedTasks.push({ id: check.taskMapping, name: taskInfo.name });
170186
}
171187
}
172-
// Collect required variables
173188
if (check.variables) {
174189
for (const variable of check.variables) {
175190
if (variable.required) {

apps/api/src/integration-platform/services/auto-check-runner.service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,17 @@ export class AutoCheckRunnerService {
4444
return { canRun: false, reason: 'No checks defined for this provider' };
4545
}
4646

47-
// Collect all required variables from all checks
47+
// Collect all required variables (manifest-level and check-level)
4848
const requiredVariables = new Set<string>();
49+
50+
// Manifest-level variables
51+
for (const variable of manifest.variables || []) {
52+
if (variable.required) {
53+
requiredVariables.add(variable.id);
54+
}
55+
}
56+
57+
// Check-level variables
4958
for (const check of manifest.checks) {
5059
if (check.variables) {
5160
for (const variable of check.variables) {

apps/app/src/app/(app)/[orgId]/cloud-tests/page.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,35 @@ import { TestsLayout } from './components/TestsLayout';
77

88
const CLOUD_PROVIDER_SLUGS = ['aws', 'gcp', 'azure'];
99

10-
// Get required variables from manifest
10+
// Get required variables from manifest (both manifest-level and check-level)
1111
const getRequiredVariables = (providerSlug: string): string[] => {
1212
const manifest = getManifest(providerSlug);
13-
if (!manifest?.checks) return [];
13+
if (!manifest) return [];
1414

1515
const requiredVars = new Set<string>();
16-
for (const check of manifest.checks) {
17-
if (check.variables) {
18-
for (const variable of check.variables) {
19-
if (variable.required) {
20-
requiredVars.add(variable.id);
16+
17+
// Check manifest-level variables
18+
if (manifest.variables) {
19+
for (const variable of manifest.variables) {
20+
if (variable.required) {
21+
requiredVars.add(variable.id);
22+
}
23+
}
24+
}
25+
26+
// Check check-level variables
27+
if (manifest.checks) {
28+
for (const check of manifest.checks) {
29+
if (check.variables) {
30+
for (const variable of check.variables) {
31+
if (variable.required) {
32+
requiredVars.add(variable.id);
33+
}
2134
}
2235
}
2336
}
2437
}
38+
2539
return Array.from(requiredVars);
2640
};
2741

0 commit comments

Comments
 (0)