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
19 changes: 17 additions & 2 deletions GUI/src/services/service-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,13 +826,27 @@ function handleAssignStep(

finishedFlow.set(parentStepName, {
assign: parentNode.data.assignElements?.reduce((acc: Record<string, any>, e: Assign) => {
acc[e.key] = e.value;
acc[e.key] = normalizeAssignValue(e.value);
return acc;
}, {}),
next: childNode ? toSnakeCase(childNode.data.label ?? 'format_messages') : 'format_messages',
});
}

/**
* Ruuter injects JSON.parse() around *_res variables when they appear inside function calls
* (e.g. String(testAPI_res.response.body[...])), causing failures because _res variables
* are already parsed objects. Strip String() wrappers from API response variable expressions
* so Ruuter handles them via direct property access (which works correctly).
*/
function normalizeAssignValue(value: string): string {
const match = /^\$\{String\(([\s\S]*)\)\}$/.exec(value);
if (match && /\b\w+_res\b/.test(match[1])) {
return '${' + match[1] + '}';
}
return value;
}

function handleEndpointStep(
parentNode: Node<NodeDataProps>,
finishedFlow: Map<any, any>,
Expand Down Expand Up @@ -866,7 +880,8 @@ function handleEndpointStep(

if (isRawBodySelected) {
try {
const rawJson = JSON.parse(rawBody?.value ?? '');
const rawJsonStr = (rawBody?.value ?? '').replace(/(?<!")(\$\{[^}]+\})(?!")/g, '"$1"');
const rawJson = JSON.parse(rawJsonStr);
stepConfig.args.body = rawJson;
} catch (e: any) {
console.log(`Unable to save JSON to Yaml. ${e.message}`);
Expand Down
8 changes: 5 additions & 3 deletions GUI/src/services/service-tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export const runServiceTest = async (input: string, serviceName?: string) => {

const { state, name, serviceStore } = serviceData;

const invalidNodes = getInvalidNodes(serviceStore.nodes);
// Clear previous test states first so stale testingPassed:false doesn't block re-runs
clearPreviousTestStates(serviceStore);

// Re-read fresh nodes from store after clearing (serviceStore.nodes is a stale snapshot)
const invalidNodes = getInvalidNodes(useServiceStore.getState().nodes);
if (invalidNodes.length > 0) {
reportInvalidNodes(invalidNodes);
return true;
Expand All @@ -38,8 +42,6 @@ export const runServiceTest = async (input: string, serviceName?: string) => {
const nameToUse = serviceName ?? name;
const stateToUse = state == ServiceState.Ready ? ServiceState.Draft : state;

clearPreviousTestStates(serviceStore);

try {
await executeServiceTest(headerValue, stateToUse, nameToUse, input.split(','));

Expand Down
3 changes: 2 additions & 1 deletion GUI/src/store/new-services.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@
});

const initialHistoryState = {
nodes: JSON.parse(JSON.stringify(nodes)),

Check warning on line 459 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ2&open=AZ4gHKttkiqBjuV3ZDQ2&pullRequest=1003
edges: JSON.parse(JSON.stringify(edges)),

Check warning on line 460 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ3&open=AZ4gHKttkiqBjuV3ZDQ3&pullRequest=1003
};

set({
Expand Down Expand Up @@ -858,12 +858,12 @@

const currentState = stateOverride
? {
nodes: JSON.parse(JSON.stringify(stateOverride.nodes)),

Check warning on line 861 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ4&open=AZ4gHKttkiqBjuV3ZDQ4&pullRequest=1003
edges: JSON.parse(JSON.stringify(stateOverride.edges)),

Check warning on line 862 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ5&open=AZ4gHKttkiqBjuV3ZDQ5&pullRequest=1003
}
: {
nodes: JSON.parse(JSON.stringify(nodes)),

Check warning on line 865 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ6&open=AZ4gHKttkiqBjuV3ZDQ6&pullRequest=1003
edges: JSON.parse(JSON.stringify(edges)),

Check warning on line 866 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ7&open=AZ4gHKttkiqBjuV3ZDQ7&pullRequest=1003
};

const lastState = history[historyIndex];
Expand Down Expand Up @@ -891,7 +891,7 @@
const { history, historyIndex } = get();
if (historyIndex > 0) {
const previousState = history[historyIndex - 1];
let nodes = JSON.parse(JSON.stringify(previousState.nodes));

Check warning on line 894 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ8&open=AZ4gHKttkiqBjuV3ZDQ8&pullRequest=1003

nodes = nodes.map((node: any) => {
if (node.type !== 'custom') return node;
Expand All @@ -909,7 +909,7 @@

set({
nodes: nodes,
edges: JSON.parse(JSON.stringify(previousState.edges)),

Check warning on line 912 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ9&open=AZ4gHKttkiqBjuV3ZDQ9&pullRequest=1003
historyIndex: historyIndex - 1,
hasUnsavedChanges: true,
});
Expand All @@ -920,7 +920,7 @@
const { history, historyIndex } = get();
if (historyIndex < history.length - 1) {
const nextState = history[historyIndex + 1];
let nodes = JSON.parse(JSON.stringify(nextState.nodes));

Check warning on line 923 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ-&open=AZ4gHKttkiqBjuV3ZDQ-&pullRequest=1003

nodes = nodes.map((node: any) => {
if (node.type !== 'custom') return node;
Expand All @@ -938,7 +938,7 @@

set({
nodes: nodes,
edges: JSON.parse(JSON.stringify(nextState.edges)),

Check warning on line 941 in GUI/src/store/new-services.store.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))` to create a deep clone.

See more on https://sonarcloud.io/project/issues?id=buerokratt_Service-Module&issues=AZ4gHKttkiqBjuV3ZDQ_&open=AZ4gHKttkiqBjuV3ZDQ_&pullRequest=1003
historyIndex: historyIndex + 1,
hasUnsavedChanges: true,
});
Expand All @@ -955,7 +955,8 @@

if (isRawBodySelected) {
try {
const rawJson = JSON.parse(rawBody?.value ?? '');
const rawJsonStr = (rawBody?.value ?? '').replace(/(?<!")(\$\{[^}]+\})(?!")/g, '"$1"');
const rawJson = JSON.parse(rawJsonStr);
body = rawJson;
} catch (e: any) {
body = extractMapValues(endpoint.body);
Expand Down
Loading