Skip to content

Commit 5b4bbad

Browse files
committed
fix(import): throw on missing required fields in getMemoryDetail instead of silent defaults
Previously, missing id/arn/name/eventExpiryDuration/strategy.type were silently replaced with empty strings or default values, hiding API response issues that would cause broken imports downstream.
1 parent 0300fb0 commit 5b4bbad

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

src/cli/aws/agentcore-control.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,33 @@ export async function getMemoryDetail(options: GetMemoryOptions): Promise<Memory
280280
throw new Error(`No memory found for ID ${options.memoryId}`);
281281
}
282282

283+
if (!memory.id) {
284+
throw new Error(`Memory ${options.memoryId} is missing required field: id`);
285+
}
286+
if (!memory.arn) {
287+
throw new Error(`Memory ${options.memoryId} is missing required field: arn`);
288+
}
289+
if (!memory.name) {
290+
throw new Error(`Memory ${options.memoryId} is missing required field: name`);
291+
}
292+
if (memory.eventExpiryDuration == null) {
293+
throw new Error(`Memory ${options.memoryId} is missing required field: eventExpiryDuration`);
294+
}
295+
283296
return {
284-
memoryId: memory.id ?? '',
285-
memoryArn: memory.arn ?? '',
286-
name: memory.name ?? '',
297+
memoryId: memory.id,
298+
memoryArn: memory.arn,
299+
name: memory.name,
287300
status: memory.status ?? 'UNKNOWN',
288301
description: memory.description,
289-
eventExpiryDuration: memory.eventExpiryDuration ?? 30,
302+
eventExpiryDuration: memory.eventExpiryDuration,
290303
strategies: (memory.strategies ?? []).map(s => {
304+
if (!s.type) {
305+
throw new Error(`Memory ${options.memoryId} has a strategy with missing required field: type`);
306+
}
291307
const episodicNamespaces = s.configuration?.reflection?.episodicReflectionConfiguration?.namespaces;
292308
return {
293-
type: s.type ?? 'SEMANTIC',
309+
type: s.type,
294310
name: s.name,
295311
description: s.description,
296312
namespaces: s.namespaces,

0 commit comments

Comments
 (0)