Skip to content
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
32 changes: 28 additions & 4 deletions Localize/lang/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"/LO3Ia": "Testing",
"/NtebP": "(UTC+05:00) Islamabad, Karachi",
"/QqADs": "Returns the elements in the array starting at index Count",
"/RFd5i": "Successfully created the group.",
"/RS9F7": "(UTC-06:00) Saskatchewan",
"/ULFwg": "Change connection",
"/VcZ9g": "This connector has multiple versions, built-in and Azure-hosted. Use built-in for the best performance, connection-string authentication, and other features. Use Azure-hosted for other authentication options.",
Expand Down Expand Up @@ -621,6 +622,7 @@
"9hKeBq": "Select an Azure OpenAI resource",
"9klmbJ": "Save",
"9lP2zW": "Please select tool",
"9mG3yl": "Failed to update connection",
"9mjZIW": "Delete handoff",
"9nAAU/": "Connections",
"9o9MIz": "Set up a database for your knowledge base.",
Expand Down Expand Up @@ -834,6 +836,7 @@
"EFQ56R": "Source code",
"EHLy1u": "Hub name can't exceed 244 characters.",
"EMcFck": "Some parameters might need configuration. Review before you continue.",
"ENMteK": "File has been successfully uploaded in knowledge hub {groupName}.",
"EPvt2J": "Select an Azure AI resource",
"ES5vsI": "Value",
"ESZXfC": "At these minutes",
Expand Down Expand Up @@ -865,7 +868,6 @@
"F2wR+r": "Insert expression",
"F3IDl8": "Required. The number of a specified time unit to add.",
"F3q0Hk": "Cannot paste actions below agents in agent to agent workflows",
"F6xkfB": "Please create a connection to add knowledge hubs.",
"F83QRP": "On a schedule",
"F9dR1Q": "Add",
"F9yRDC": "Method",
Expand Down Expand Up @@ -950,6 +952,7 @@
"GusLAj": "Case",
"Gw0u+P": "EDI",
"GxdV2y": "Expires",
"GyPgdO": "Failed to create group",
"GyUe4C": "Modify options regarding functions",
"GzQQqH": "Array",
"H/QVod": "Workflow has settings validation errors on the following operations: {invalidNodes}",
Expand Down Expand Up @@ -992,6 +995,7 @@
"HuWIbw": "Package warning",
"HzS2gJ": "Dynamic content not supported as properties in authentication.",
"I+85NV": "Submit from this action",
"I1A+Jw": "Connection created",
"I1CYNA": "Invalid property ''{invalidProperties}'' for authentication type ''{authType}''.",
"I1xjeq": "The name {name} is already in use. Please choose a different name.",
"I2XWRg": "Add",
Expand Down Expand Up @@ -1416,6 +1420,7 @@
"QNfUf/": "Full screen",
"QT4IaP": "Filtered!",
"QVtqAn": "Description",
"QW+oZz": "Successfully updated details for knowledge hub connection.",
"QZBPUx": "Returns a single value matching the key name from form-data or form-encoded trigger output",
"QZnOGQ": "Managed connections",
"QZrxUk": "String functions",
Expand All @@ -1440,6 +1445,7 @@
"Qvk1rO": "Save",
"QwAEWd": "Select a project",
"QxEQwD": "Status",
"QzjaQG": "Connection updated",
"R/aiRy": "(UTC+12:00) Coordinated Universal Time+12",
"R0Skk9": "Confirm that you want to delete this artifact? You can't undo this action.",
"R7UxBX": "Learn more",
Expand Down Expand Up @@ -1979,6 +1985,7 @@
"_/LO3Ia.comment": "The text for the testing environment",
"_/NtebP.comment": "Time zone value ",
"_/QqADs.comment": "Label for description of custom skip Function",
"_/RFd5i.comment": "Title for the toaster after creating a group in add files panel",
"_/RS9F7.comment": "Time zone value ",
"_/ULFwg.comment": "Button text to take the user to the 'change connection' component",
"_/VcZ9g.comment": "Description about hybrid connectors",
Expand Down Expand Up @@ -2539,6 +2546,7 @@
"_9hKeBq.comment": "Select the Azure Cognitive Service Open AI resource to use for this connection",
"_9klmbJ.comment": "Button text for saving changes for parameter in the customize parameter panel",
"_9lP2zW.comment": "Placeholder text for tool selection dropdown",
"_9mG3yl.comment": "Error title when connection update fails",
"_9mjZIW.comment": "Text for button to delete a handoff",
"_9nAAU/.comment": "Connections button",
"_9o9MIz.comment": "Description for the database section in basics tab for quick app create panel",
Expand Down Expand Up @@ -2752,6 +2760,7 @@
"_EFQ56R.comment": "Link to the source code of the template",
"_EHLy1u.comment": "Error message when the hub name exceeds maximum length.",
"_EMcFck.comment": "The description for the actions information section",
"_ENMteK.comment": "Notification content for successful file upload in add files panel",
"_EPvt2J.comment": "Select the Azure Cognitive Service AI resource to use for this connection",
"_ES5vsI.comment": "Value",
"_ESZXfC.comment": "Label for schedule minutes",
Expand Down Expand Up @@ -2783,7 +2792,6 @@
"_F2wR+r.comment": "Label for button to open expression token picker",
"_F3IDl8.comment": "Required integer parameter to add to time",
"_F3q0Hk.comment": "Message shown when paste is disabled below agents in A2A workflows",
"_F6xkfB.comment": "Text to indicate that there is no connection",
"_F83QRP.comment": "Schedule trigger category",
"_F9dR1Q.comment": "Add",
"_F9yRDC.comment": "Label for the authentication method",
Expand Down Expand Up @@ -2868,6 +2876,7 @@
"_GusLAj.comment": "Label for the case node",
"_Gw0u+P.comment": "EDI category",
"_GxdV2y.comment": "Label for the key expiration",
"_GyPgdO.comment": "Error title when group creation fails",
"_GyUe4C.comment": "Description for the functions section",
"_GzQQqH.comment": "This is an option in a dropdown where users can select type Array for their parameter.",
"_H/QVod.comment": "Error message to show when there are invalid connections in the nodes.",
Expand Down Expand Up @@ -2910,6 +2919,7 @@
"_HuWIbw.comment": "Package warning message",
"_HzS2gJ.comment": "Error message for when putting token in authentication property",
"_I+85NV.comment": "Button label for submitting a workflow to rerun from this action",
"_I1A+Jw.comment": "Notification title for successful connection creation",
"_I1CYNA.comment": "Error message when having an invalid authentication property",
"_I1xjeq.comment": "Error message when the name is already in use",
"_I2XWRg.comment": "Button text for opening panel for adding workflows",
Expand Down Expand Up @@ -3334,6 +3344,7 @@
"_QNfUf/.comment": "Full Screen token picker",
"_QT4IaP.comment": "Filtered text",
"_QVtqAn.comment": "Label for description column.",
"_QW+oZz.comment": "Notification content for successful connection update",
"_QZBPUx.comment": "Label for description of custom triggerFormDataValue Function",
"_QZnOGQ.comment": "Managed connections label",
"_QZrxUk.comment": "Label for string functions",
Expand All @@ -3358,6 +3369,7 @@
"_Qvk1rO.comment": "Button text for updating action selections",
"_QwAEWd.comment": "Select the project to use for this connection",
"_QxEQwD.comment": "Status filter label",
"_QzjaQG.comment": "Notification title for successful connection update",
"_R/aiRy.comment": "Time zone value ",
"_R0Skk9.comment": "Content for the delete artifact",
"_R7UxBX.comment": "Link text for learning more about knowledge base group",
Expand Down Expand Up @@ -3940,7 +3952,6 @@
"_c8UPLp.comment": "Section 2 of text for including dynamic content section",
"_c8dbb/.comment": "Prompt to encourage searching in large datasets",
"_cAPPxZ.comment": "Label for subscription dropdown",
"_cBQnzA.comment": "Text to indicate that there are no artifacts in the knowledge hub",
"_cBw7SC.comment": "Label for connection creation date",
"_cHiBAn.comment": "Time zone value ",
"_cJkSrD.comment": "tooltip text of pagination setting",
Expand Down Expand Up @@ -4291,6 +4302,7 @@
"_iq+tiv.comment": "Hour of the day",
"_iql+jn.comment": "This is a period in time in seconds. {seconds} is replaced by the number and s is an abbreviation of seconds",
"_ir+plQ.comment": "title for panel error",
"_isF2bJ.comment": "Error message when group creation fails",
"_ituHoi.comment": "Trigger badge text",
"_iuh4i3.comment": "Created date label",
"_iwKxSD.comment": "Connection authenticated text",
Expand Down Expand Up @@ -4346,6 +4358,7 @@
"_k/X2ml.comment": "Title for solution type",
"_k/oqFL.comment": "Required base64 string parameter to be converted using base64ToString function",
"_k2a8ry.comment": "The tab label for the summary tab on the configure template wizard",
"_k47GxU.comment": "Error title when connection creation fails",
"_k5tGEr.comment": "This is the boolean value for Yes",
"_k6MqI+.comment": "Creating workspace in progress",
"_k8cbQ1.comment": "Header for the node parameter errors subsection",
Expand All @@ -4356,6 +4369,7 @@
"_kHcCxH.comment": "This is a time duration in abbreviated format",
"_kHs5R4.comment": "Chatbot flow preview message reminding user to check workflow actions",
"_kIei9R.comment": "Text that explains no tools exist in this agent",
"_kIxrfq.comment": "Text to indicate that there are no artifacts in the knowledge hub",
"_kKJMeM.comment": "Example of a sentence that the user should complete",
"_kLqXDY.comment": "Label for workflow Name",
"_kM+Mr0.comment": "Loading text when items are being fetched",
Expand Down Expand Up @@ -4727,12 +4741,14 @@
"_rREwxg.comment": "Refresh button",
"_rSIBjh.comment": "Parameter Field Value Placeholder Text",
"_rSa1Id.comment": "Files could not be found in specified path",
"_rUgi69.comment": "Notification title for successful file upload in add files panel",
"_raBiud.comment": "Require parameters to find maximum using max function",
"_rbVW+z.comment": "Last 24 hours filter",
"_rcz4w4.comment": "Label for description of custom uriComponent Function",
"_rd6fai.comment": "Aria describing the way to control the keyboard navigation",
"_rh5g4p.comment": "Successful run",
"_rhBKTF.comment": "Error shown when the template skus are empty",
"_rj0Nby.comment": "Notification content for successful connection creation",
"_rl9UOO.comment": "Descriptive message to show if the connection for an action cannot be changed or edited due to being shown in dual-pane (pinned action) view.",
"_rlfK4u.comment": "Content for the toaster for after saving template.",
"_rsdJcV.comment": "Main message displayed in the placeholder",
Expand All @@ -4741,6 +4757,7 @@
"_rxMXmZ.comment": "Time zone value ",
"_s+4LEa.comment": "Open folder label",
"_s0Qaot.comment": "Workflow Parameters Panel",
"_s2f0XK.comment": "Content for the toaster after creating a group in add files panel",
"_s2ydQX.comment": "Error validation message for invalid JSON object. Do not remove the double single quotes around the display name, as it is needed to wrap the placeholder text.",
"_s4omwa.comment": "Assertion field description title",
"_s5AOpV.comment": "Label for the title for panel header card",
Expand Down Expand Up @@ -5038,6 +5055,7 @@
"_woJtvu.comment": "Label text for subscriptions filter",
"_wtj07J.comment": "Time zone value ",
"_ww1mN/.comment": "Button text for showing the canvas view",
"_wwXFYB.comment": "Text to indicate that there is no connection",
"_wx/ZQP.comment": "Add Input",
"_wxZy/s.comment": "App event trigger category",
"_wxaQwD.comment": "Time zone value ",
Expand Down Expand Up @@ -5280,7 +5298,6 @@
"c8UPLp": "Dynamic content may also be added from other sources.",
"c8dbb/": "Type to search {options} items or scroll to see more...",
"cAPPxZ": "Subscription",
"cBQnzA": "No hub artifacts found. You can create hub and upload files to get started.",
"cBw7SC": "Created",
"cHiBAn": "(UTC+09:00) Seoul",
"cJkSrD": "Retrieve more results up to the pagination limit",
Expand Down Expand Up @@ -5631,6 +5648,7 @@
"iq+tiv": "11",
"iql+jn": "{seconds}s",
"ir+plQ": "Operation details error",
"isF2bJ": "Failed to create group: {errorMessage}",
"ituHoi": "Trigger",
"iuh4i3": "Created date",
"iwKxSD": "Authenticated",
Expand Down Expand Up @@ -5686,6 +5704,7 @@
"k/X2ml": "Type",
"k/oqFL": "Required. The base64 encoded string.",
"k2a8ry": "Review + publish",
"k47GxU": "Failed to create connection",
"k5tGEr": "Yes",
"k6MqI+": "Creating...",
"k8cbQ1": "Parameter errors",
Expand All @@ -5696,6 +5715,7 @@
"kHcCxH": "{minutes}m {seconds}s",
"kHs5R4": "Check these actions to see if any parameters need to be set.",
"kIei9R": "Add an MCP server (preview)",
"kIxrfq": "Can't find knowledge base artifacts. Create a knowledge base and upload files to get started.",
"kKJMeM": "Every week on Monday...",
"kLqXDY": "Name",
"kM+Mr0": "Loading...",
Expand Down Expand Up @@ -6067,12 +6087,14 @@
"rREwxg": "Refresh",
"rSIBjh": "Enter value for parameter.",
"rSa1Id": "No files found in {filePath}, please save XSLT to specified path to use this function",
"rUgi69": "File uploaded",
"raBiud": "Required. Either an array of values to find the maximum value, or the first value of a set.",
"rbVW+z": "Last 24 hours",
"rcz4w4": "Returns a URI encoded representation of a value",
"rd6fai": "Use left and right arrow keys to navigate between commands",
"rh5g4p": "Is successful",
"rhBKTF": "Atleast one sku is required for publish.",
"rj0Nby": "Knowledge hub connection has been created successfully.",
"rl9UOO": "Connections cannot be edited in pinned view. Release the pinned action to make connection changes.",
"rlfK4u": "Your template in action is in development mode.",
"rsdJcV": "Select source schema elements to build your map",
Expand All @@ -6081,6 +6103,7 @@
"rxMXmZ": "(UTC+04:00) Port Louis",
"s+4LEa": "Open folder",
"s0Qaot": "Workflow Parameters Panel",
"s2f0XK": "Group {name} has been created and selected.",
"s2ydQX": "''Value'' must be a valid JSON object",
"s4omwa": "Description",
"s5AOpV": "Card title",
Expand Down Expand Up @@ -6378,6 +6401,7 @@
"woJtvu": "Subscriptions",
"wtj07J": "(UTC-09:30) Marquesas Islands",
"ww1mN/": "Canvas",
"wwXFYB": "Create a connection to add knowledge hubs.",
"wx/ZQP": "Add Input",
"wxZy/s": "From an app",
"wxaQwD": "(UTC+04:30) Kabul",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@ vi.mock('@microsoft/logic-apps-shared', () => ({
return defaultMessage;
}

return defaultMessage.replace(/\{([^}]+)\}/g, (_, key) => values[key] ?? `{${key}}`);
return defaultMessage.replace(/\{([^}]+)\}/g, (_: any, key: string | number) => values[key] ?? `{${key}}`);
}),
})),
getPropertyValue: vi.fn((obj, key) => obj?.[key]),
getObjectPropertyValue: vi.fn((obj, path) => path.reduce((acc: any, currentKey: string) => acc?.[currentKey], obj)),
ConnectionType: {
KnowledgeHub: 'KnowledgeHub',
},
LogEntryLevel: {
Error: 'Error',
Warning: 'Warning',
Debug: 'Debug',
Trace: 'Trace',
Verbose: 'Verbose',
},
LoggerService: vi.fn(() => ({
log: vi.fn(),
})),
}));

vi.mock('../../../ReactQueryProvider', () => ({
Expand Down
26 changes: 17 additions & 9 deletions libs/designer/src/lib/core/knowledge/utils/__test__/helper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ vi.mock('@microsoft/logic-apps-shared', () => ({
}),
isNullOrEmpty: (value: string | undefined | null) => value === undefined || value === null || value === '',
equals: (a: string, b: string) => a?.toLowerCase() === b?.toLowerCase(),
getObjectPropertyValue: (obj: any, path: string[]) => {
let current = obj;
for (const key of path) {
if (current === null || current === undefined) {
return undefined;
}
current = current[key];
}
return current;
},
}));

describe('knowledge helper utils', () => {
Expand All @@ -44,7 +54,7 @@ describe('knowledge helper utils', () => {
'api-version': '2018-11-01',
'Content-Type': 'application/json',
},
JSON.stringify({ description })
{ description }
);
});

Expand All @@ -57,11 +67,11 @@ describe('knowledge helper utils', () => {
expect(result).toEqual(response);
});

it('should log error when API call fails', async () => {
it('should log error and throw when API call fails', async () => {
const errorResponse = { error: { code: 'BadRequest', message: 'Invalid hub name' } };
mockExecuteResourceAction.mockRejectedValue(errorResponse);

await createKnowledgeHub(siteResourceId, groupName, description);
await expect(createKnowledgeHub(siteResourceId, groupName, description)).rejects.toThrow('Invalid hub name');

expect(mockLog).toHaveBeenCalledTimes(1);
expect(mockLog).toHaveBeenCalledWith({
Expand All @@ -72,23 +82,21 @@ describe('knowledge helper utils', () => {
});
});

it('should return undefined when API call fails', async () => {
it('should throw error when API call fails', async () => {
mockExecuteResourceAction.mockRejectedValue({ error: { message: 'Failed' } });

const result = await createKnowledgeHub(siteResourceId, groupName, description);

expect(result).toBeUndefined();
await expect(createKnowledgeHub(siteResourceId, groupName, description)).rejects.toThrow('Failed');
});

it('should handle error response without error property', async () => {
mockExecuteResourceAction.mockRejectedValue({ message: 'Network error' });

await createKnowledgeHub(siteResourceId, groupName, description);
await expect(createKnowledgeHub(siteResourceId, groupName, description)).rejects.toThrow('Network error');

expect(mockLog).toHaveBeenCalledWith({
level: 'Error',
area: 'KnowledgeHub.createKnowledgeHub',
error: {},
error: { message: 'Network error' },
message: `Error while creating knowledge hub for the app: ${siteResourceId}`,
});
});
Expand Down
19 changes: 17 additions & 2 deletions libs/designer/src/lib/core/knowledge/utils/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import type {
Connector,
Connection,
} from '@microsoft/logic-apps-shared';
import { ConnectionService, getIntl, ConnectionType, getObjectPropertyValue } from '@microsoft/logic-apps-shared';
import {
ConnectionService,
getIntl,
ConnectionType,
getObjectPropertyValue,
LogEntryLevel,
LoggerService,
} from '@microsoft/logic-apps-shared';
import type { IntlShape } from 'react-intl';
import { getReactQueryClient } from '../../ReactQueryProvider';

Expand Down Expand Up @@ -358,7 +365,7 @@ export const getCosmosDbConnectionParameters = (intl: IntlShape): ConnectionPara
};
};

export const createOrUpdateConnection = async (parameterValues: Record<string, any>) => {
export const createOrUpdateConnection = async (parameterValues: Record<string, any>, isCreate = true) => {
const intl = getIntl();
const connectionParameters = getAllConnectionParameters(intl) as unknown as Record<string, ConnectionParameter>;
const displayName = parameterValues.displayName;
Expand All @@ -377,6 +384,14 @@ export const createOrUpdateConnection = async (parameterValues: Record<string, a
return connection;
} catch (error: any) {
const errorMessage = getObjectPropertyValue(error, ['error', 'message']) ?? getObjectPropertyValue(error, ['message']);

LoggerService().log({
level: LogEntryLevel.Error,
area: `KnowledgeHub.${isCreate ? 'Create' : 'Update'}Connection`,
error,
message: `Failed to ${isCreate ? 'create' : 'update'} connection with display name ${displayName}`,
});

throw new Error(
intl.formatMessage(
{
Expand Down
Loading
Loading