I am consistently getting this error when attempting to execute my typescript function below:
{"errorCode":"INVALID_ARGUMENT","errorName":"InvalidParameterValue","errorInstanceId":"35b4668f-8456-40f1-b4dc-2c5ea714f8e0","parameters":{"parameterBaseType":"Integer","parameterId":"lockUntil","parameterValue":1753653763405}}
The function code:
@Edits(MachineExecutions)
@OntologyEditFunction()
public async updateMachine(
id: string,
stateMachine: string,
state: string,
logs: string | undefined,
lockOwner: string | undefined,
lockUntil: Integer | undefined,
): Promise<void> {
const solution = {
input: '', //not relevant for this
id: id || Uuid.random(),
plan: '', //not relevant for this
};
let machine = Objects.search().machineExecutions().filter(item => item.id.exactMatch(id)).all()?.[0];
if (!machine) {
machine = Objects.create().machineExecutions(solution.id);
}
machine.machine = stateMachine;
machine.state = state;
machine.logs = logs;
machine.currentState = JSON.parse(state).value;
// set the mutex
if (lockOwner && lockOwner.length > 0) {
if (!lockUntil) {
throw new Error('lockUntil must be defined when setting a lock owner!')
}
if (new Date(lockUntil).getTime() - Date.now() > 30 * 60 * 1000) {
throw new Error('Invalid lock expire. The lockUntil value can not result in a date the is greater that 30 mins from now.')
}
machine.lockOwner = lockOwner;
machine.lockUntil = Timestamp.fromJsDate(new Date(lockUntil))
}
}
My function is never called when this error is received. The execution is blocked by the functions API. The only thing I can surmise is that functions are making sure the timestamp doesn’t occur in the future. Is this what is occurring, or is something else causing this issue?