Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cartermak opened this issue Jan 15, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@cartermak
Copy link
Member

cartermak commented Jan 15, 2025

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

@cartermak cartermak added the bug Something isn't working label Jan 15, 2025
@github-project-automation github-project-automation bot moved this to Todo in Aerie Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

1 participant