mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 18:10:39 +09:00
fix(routines): address Greptile review findings
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
38a0cd275e
commit
fd6cfc7149
5 changed files with 77 additions and 21 deletions
|
|
@ -466,6 +466,54 @@ describeEmbeddedPostgres("routine service live-execution coalescing", () => {
|
|||
).rejects.toThrow(/require defaults for required variables/i);
|
||||
});
|
||||
|
||||
it("treats malformed stored defaults as missing when validating schedule triggers", async () => {
|
||||
const { companyId, agentId, projectId, svc } = await seedFixture();
|
||||
const variableRoutine = await svc.create(
|
||||
companyId,
|
||||
{
|
||||
projectId,
|
||||
goalId: null,
|
||||
parentIssueId: null,
|
||||
title: "ship check",
|
||||
description: "Review {{approved}}",
|
||||
assigneeAgentId: agentId,
|
||||
priority: "medium",
|
||||
status: "active",
|
||||
concurrencyPolicy: "coalesce_if_active",
|
||||
catchUpPolicy: "skip_missed",
|
||||
variables: [
|
||||
{ name: "approved", label: null, type: "boolean", defaultValue: true, required: true, options: [] },
|
||||
],
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
await db
|
||||
.update(routines)
|
||||
.set({
|
||||
variables: [
|
||||
{
|
||||
name: "approved",
|
||||
label: null,
|
||||
type: "boolean",
|
||||
defaultValue: "definitely",
|
||||
required: true,
|
||||
options: [],
|
||||
},
|
||||
],
|
||||
})
|
||||
.where(eq(routines.id, variableRoutine.id));
|
||||
|
||||
await expect(
|
||||
svc.createTrigger(variableRoutine.id, {
|
||||
kind: "schedule",
|
||||
label: "daily",
|
||||
cronExpression: "0 10 * * *",
|
||||
timezone: "UTC",
|
||||
}, {}),
|
||||
).rejects.toThrow(/require defaults for required variables/i);
|
||||
});
|
||||
|
||||
it("serializes concurrent dispatches until the first execution issue is linked to a queued run", async () => {
|
||||
const { routine, svc } = await seedFixture({
|
||||
wakeup: async (wakeupAgentId, wakeupOpts) => {
|
||||
|
|
|
|||
|
|
@ -213,7 +213,13 @@ function sanitizeRoutineVariableInputs(
|
|||
function assertScheduleCompatibleVariables(variables: RoutineVariable[]) {
|
||||
const missingDefaults = variables
|
||||
.filter((variable) => variable.required)
|
||||
.filter((variable) => isMissingRoutineVariableValue(normalizeRoutineVariableValue(variable, variable.defaultValue)))
|
||||
.filter((variable) => {
|
||||
try {
|
||||
return isMissingRoutineVariableValue(normalizeRoutineVariableValue(variable, variable.defaultValue));
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.map((variable) => variable.name);
|
||||
if (missingDefaults.length > 0) {
|
||||
throw unprocessable(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue