Skip to content

Commit 70b77b4

Browse files
Merge pull request #1090 from smalruby/fix/shared-assignments-mine-500
fix(classroom): mine=1 の shared list が空 ExpressionAttributeNames で 500
2 parents adb744e + 1e06e2f commit 70b77b4

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

infra/smalruby-classroom/lambda/handler.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3752,14 +3752,17 @@ async function handleListSharedAssignments(
37523752
}
37533753
}
37543754

3755+
// DynamoDB rejects an EMPTY ExpressionAttributeNames map, so the key must
3756+
// be omitted when there is nothing to alias (mine=1 with no filters).
3757+
const expressionNames = {
3758+
...(mine ? {} : { '#status': 'status' }),
3759+
...names,
3760+
};
37553761
const result = await docClient.send(new QueryCommand({
37563762
TableName: SHARED_ASSIGNMENTS_TABLE,
37573763
IndexName: mine ? 'authorSub-createdAt-index' : 'status-createdAt-index',
37583764
KeyConditionExpression: mine ? 'authorSub = :pk' : '#status = :pk',
3759-
ExpressionAttributeNames: {
3760-
...(mine ? {} : { '#status': 'status' }),
3761-
...names,
3762-
},
3765+
...(Object.keys(expressionNames).length > 0 ? { ExpressionAttributeNames: expressionNames } : {}),
37633766
ExpressionAttributeValues: {
37643767
':pk': mine ? identity.sub : 'published',
37653768
...values,

infra/smalruby-classroom/lambda/tests/handler-shared-assignments.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ describe('みんなの課題 (issue #1068)', () => {
325325
}));
326326
expect(captured?.IndexName).toBe('authorSub-createdAt-index');
327327
expect((captured?.ExpressionAttributeValues as Record<string, unknown>)[':pk']).toBe('dev-test-teacher');
328+
// DynamoDB rejects an EMPTY ExpressionAttributeNames map — with no
329+
// filters and no #status alias, the key must be omitted entirely
330+
// (prod 500 on 自分の投稿, 2026-07-18).
331+
expect(captured?.ExpressionAttributeNames).toBeUndefined();
328332
expect(JSON.parse(res.body as string).items[0].status).toBe('unlisted');
329333
});
330334
});

0 commit comments

Comments
 (0)