Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions infra/smalruby-classroom/lambda/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3752,14 +3752,17 @@ async function handleListSharedAssignments(
}
}

// DynamoDB rejects an EMPTY ExpressionAttributeNames map, so the key must
// be omitted when there is nothing to alias (mine=1 with no filters).
const expressionNames = {
...(mine ? {} : { '#status': 'status' }),
...names,
};
const result = await docClient.send(new QueryCommand({
TableName: SHARED_ASSIGNMENTS_TABLE,
IndexName: mine ? 'authorSub-createdAt-index' : 'status-createdAt-index',
KeyConditionExpression: mine ? 'authorSub = :pk' : '#status = :pk',
ExpressionAttributeNames: {
...(mine ? {} : { '#status': 'status' }),
...names,
},
...(Object.keys(expressionNames).length > 0 ? { ExpressionAttributeNames: expressionNames } : {}),
ExpressionAttributeValues: {
':pk': mine ? identity.sub : 'published',
...values,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ describe('みんなの課題 (issue #1068)', () => {
}));
expect(captured?.IndexName).toBe('authorSub-createdAt-index');
expect((captured?.ExpressionAttributeValues as Record<string, unknown>)[':pk']).toBe('dev-test-teacher');
// DynamoDB rejects an EMPTY ExpressionAttributeNames map — with no
// filters and no #status alias, the key must be omitted entirely
// (prod 500 on 自分の投稿, 2026-07-18).
expect(captured?.ExpressionAttributeNames).toBeUndefined();
expect(JSON.parse(res.body as string).items[0].status).toBe('unlisted');
});
});
Expand Down
Loading