Skip to content

Sequencing server fails to deserialize Duration-type activity arguments #1625

Closed
@cartermak

Description

@cartermak

Checked for duplicates

No - I haven't checked

Is this a regression?

No - This is a new bug

Version

3.0.1

Describe the bug

The command expansion service incorrectly interprets all Duration-type activity arguments (that is, Duration as a value schema type) as having a value of zero. From a little debugging, it seems like parse is returning a duration of zero when parsing the serialized value, which comes as an integer number of microseconds.

Relevant sequencing server function:

function convertType(value: any, schema: Schema): any {
switch (schema.type) {
case SchemaTypes.Int:
if (value === null) {
return value;
}
if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER) {
return value.toString();
}
return parseInt(value, 10);
case SchemaTypes.Real:
return value;
case SchemaTypes.Duration:
if (value !== null) {
return Temporal.Duration.from(parse(value).toISOString());
}
return value;
case SchemaTypes.Boolean:
return value;
case SchemaTypes.Path:
return value;
case SchemaTypes.String:
return value;
case SchemaTypes.Series:
if (value === null) {
return value;
}
return value.map((value: any) => convertType(value, schema.items));
case SchemaTypes.Struct:
if (value === null) {
return value;
}
const struct: { [attributeName: string]: any } = {};
for (const [attributeKey, attributeSchema] of Object.entries(schema.items)) {
struct[attributeKey] = convertType(value[attributeKey], attributeSchema);
}
return struct;
case SchemaTypes.Variant:
if (value === null || (schema.variants.length === 1 && schema.variants[0]?.key === 'VOID')) {
return null;
}
return value;
default:
assertUnreachable(schema);
}
}

Reproduction

Write a command expansion rule that uses a Duration-type activity parameter and see that the value of the parameter is deserialized for use in the expansion rule as zero.

For example, the below uses GrowBanana and prints out the string value of the duration (which comes back as PT0S).

export default function MyExpansion(props: {
  activityInstance: ActivityType,
  channelDictionary: ChannelDictionary | null
  parameterDictionaries : ParameterDictionary[]
}): ExpansionReturn {
  const { startTime, attributes } = props.activityInstance;
  return [A(startTime.add(attributes.arguments.growingDuration)).SEQ_ECHO(attributes.arguments.growingDuration.toString())];
}

Logs

No response

System Info

Aerie 3.0.1 local

Severity

Moderate

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions