Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+28
@@ -25,6 +25,34 @@ describe("formatWorkflowExecutionErrorText", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("translates semantic errors persisted by background execution", () => {
|
||||
expect(formatWorkflowExecutionErrorText("workflows.executionErrors.streamFailed", t)).toBe(
|
||||
JSON.stringify({ key: "workflows.executionErrors.streamFailed", options: undefined })
|
||||
);
|
||||
});
|
||||
|
||||
it("translates semantic typed-model errors persisted by workflow blocks", () => {
|
||||
expect(formatWorkflowExecutionErrorText("workflows.errors.invalidFieldValue", t)).toBe(
|
||||
JSON.stringify({ key: "workflows.errors.invalidFieldValue", options: undefined })
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
"workflows.executionErrors.invalidInput",
|
||||
"workflows.executionErrors.invalidValidationSchema",
|
||||
"workflows.executionErrors.variableParsingFailed",
|
||||
])(
|
||||
"translates semantic validation error %s",
|
||||
(error) => {
|
||||
expect(formatWorkflowExecutionErrorText(error, t)).toBe(JSON.stringify({ key: error, options: undefined }));
|
||||
}
|
||||
);
|
||||
|
||||
it("uses localized generic copy instead of rendering a missing semantic key", () => {
|
||||
const missingKeyT = (key: string) => (key === "workflows.errors.unknown" ? "Something went wrong" : key);
|
||||
expect(formatWorkflowExecutionErrorText("workflows.executionErrors.futureFailure", missingKeyT)).toBe("Something went wrong");
|
||||
});
|
||||
|
||||
it("keeps unknown provider errors unchanged", () => {
|
||||
expect(formatWorkflowExecutionErrorText("Provider failed for https://api.example.test", t)).toBe("Provider failed for https://api.example.test");
|
||||
});
|
||||
|
||||
+5
@@ -65,6 +65,11 @@ export function formatWorkflowExecutionErrorText(error: string | null | undefine
|
||||
return "";
|
||||
}
|
||||
|
||||
if (/^workflows\.(?:executionErrors|errors)\.[A-Za-z0-9_]+$/u.test(error)) {
|
||||
const translated = t(error);
|
||||
return translated === error ? t("workflows.errors.unknown") : translated;
|
||||
}
|
||||
|
||||
for (const rule of WORKFLOW_ERROR_RULES) {
|
||||
if (typeof rule.match === "string") {
|
||||
if (rule.match === error) {
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatWorkflowInvalidSchemaText, formatWorkflowNativeCapabilityErrorText } from "./workflowPreflightErrorText";
|
||||
|
||||
const nativeCapabilityCases: Array<[string, string, Record<string, string> | undefined]> = [
|
||||
["missing trigger block", "workflows.errors.nativeCapabilityMissingTrigger", undefined],
|
||||
['unsupported block type "rowCreate" on block create_1', "workflows.errors.nativeCapabilityUnsupportedBlock", { type: "rowCreate", blockId: "create_1" }],
|
||||
['unsupported credential reference "mail" on block email_1', "workflows.errors.nativeCapabilityUnsupportedCredential", { credential: "mail", blockId: "email_1" }],
|
||||
["if block if_1 must have exactly one condition group", "workflows.errors.nativeCapabilityIfConditionGroupCount", { blockId: "if_1" }],
|
||||
["if block if_1 must have at least one condition", "workflows.errors.nativeCapabilityIfConditionRequired", { blockId: "if_1" }],
|
||||
["if block if_1 is missing false edge", "workflows.errors.nativeCapabilityIfMissingEdge", { blockId: "if_1", edge: "false" }],
|
||||
["switch block switch_1 is missing case2 edge", "workflows.errors.nativeCapabilitySwitchMissingEdge", { blockId: "switch_1", edge: "case2" }],
|
||||
["switch block switch_1 condition group 2 must have at least one condition", "workflows.errors.nativeCapabilitySwitchConditionRequired", { blockId: "switch_1", index: "2" }],
|
||||
['unsupported conditional edge "edge_1" from block log_1', "workflows.errors.nativeCapabilityUnsupportedConditionalEdge", { edgeId: "edge_1", blockId: "log_1" }],
|
||||
];
|
||||
|
||||
function t(key: string, options?: Record<string, unknown>) {
|
||||
return JSON.stringify({ key, options });
|
||||
}
|
||||
|
||||
describe("workflow preflight error text", () => {
|
||||
it("replaces raw schema parser details with a semantic summary", () => {
|
||||
expect(formatWorkflowInvalidSchemaText(t, "manual_1")).toBe(
|
||||
JSON.stringify({ key: "workflows.errors.invalidManualValidationSchemaSummary", options: { blockId: "manual_1" } })
|
||||
);
|
||||
});
|
||||
|
||||
it.each(nativeCapabilityCases)("maps %s to request-local copy", (error, key, options) => {
|
||||
expect(formatWorkflowNativeCapabilityErrorText(t, error)).toBe(JSON.stringify({ key, options }));
|
||||
});
|
||||
|
||||
it("never exposes an unknown native capability detail", () => {
|
||||
expect(formatWorkflowNativeCapabilityErrorText(t, "provider secret: sk_live_123")).toBe(
|
||||
JSON.stringify({ key: "workflows.errors.nativeCapabilityUnknown" })
|
||||
);
|
||||
});
|
||||
});
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
type WorkflowPreflightErrorT = (key: string, options?: Record<string, unknown>) => unknown;
|
||||
|
||||
type NativeCapabilityRule = {
|
||||
key: string;
|
||||
match: string | RegExp;
|
||||
params?: (match: RegExpMatchArray) => Record<string, string>;
|
||||
};
|
||||
|
||||
const NATIVE_CAPABILITY_RULES: NativeCapabilityRule[] = [
|
||||
{ match: "missing trigger block", key: "workflows.errors.nativeCapabilityMissingTrigger" },
|
||||
{
|
||||
match: /^unsupported block type "(.+)" on block (.+)$/u,
|
||||
key: "workflows.errors.nativeCapabilityUnsupportedBlock",
|
||||
params: ([, type, blockId]) => ({ type, blockId }),
|
||||
},
|
||||
{
|
||||
match: /^unsupported credential reference "(.+)" on block (.+)$/u,
|
||||
key: "workflows.errors.nativeCapabilityUnsupportedCredential",
|
||||
params: ([, credential, blockId]) => ({ credential, blockId }),
|
||||
},
|
||||
{
|
||||
match: /^if block (.+) must have exactly one condition group$/u,
|
||||
key: "workflows.errors.nativeCapabilityIfConditionGroupCount",
|
||||
params: ([, blockId]) => ({ blockId }),
|
||||
},
|
||||
{
|
||||
match: /^if block (.+) must have at least one condition$/u,
|
||||
key: "workflows.errors.nativeCapabilityIfConditionRequired",
|
||||
params: ([, blockId]) => ({ blockId }),
|
||||
},
|
||||
{
|
||||
match: /^if block (.+) is missing (true|false) edge$/u,
|
||||
key: "workflows.errors.nativeCapabilityIfMissingEdge",
|
||||
params: ([, blockId, edge]) => ({ blockId, edge }),
|
||||
},
|
||||
{
|
||||
match: /^switch block (.+) is missing (default|case\d+) edge$/u,
|
||||
key: "workflows.errors.nativeCapabilitySwitchMissingEdge",
|
||||
params: ([, blockId, edge]) => ({ blockId, edge }),
|
||||
},
|
||||
{
|
||||
match: /^switch block (.+) condition group (\d+) must have at least one condition$/u,
|
||||
key: "workflows.errors.nativeCapabilitySwitchConditionRequired",
|
||||
params: ([, blockId, index]) => ({ blockId, index }),
|
||||
},
|
||||
{
|
||||
match: /^unsupported conditional edge "(.+)" from block (.+)$/u,
|
||||
key: "workflows.errors.nativeCapabilityUnsupportedConditionalEdge",
|
||||
params: ([, edgeId, blockId]) => ({ edgeId, blockId }),
|
||||
},
|
||||
];
|
||||
|
||||
export function formatWorkflowInvalidSchemaText(t: WorkflowPreflightErrorT, blockId: string): string {
|
||||
return String(t("workflows.errors.invalidManualValidationSchemaSummary", { blockId }));
|
||||
}
|
||||
|
||||
export function formatWorkflowNativeCapabilityErrorText(t: WorkflowPreflightErrorT, error: string): string {
|
||||
for (const rule of NATIVE_CAPABILITY_RULES) {
|
||||
if (typeof rule.match === "string") {
|
||||
if (rule.match === error) {
|
||||
return String(t(rule.key));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const match = error.match(rule.match);
|
||||
if (match) {
|
||||
return String(t(rule.key, rule.params?.(match)));
|
||||
}
|
||||
}
|
||||
|
||||
return String(t("workflows.errors.nativeCapabilityUnknown"));
|
||||
}
|
||||
Reference in new issue
Block a user