Skip to content

fix(classroom): mine=1 の shared list が空 ExpressionAttributeNames で 500#1090

Merged
smalruby3-editor-bot[bot] merged 1 commit into
feature/assignment-sharingfrom
fix/shared-assignments-mine-500
Jul 18, 2026
Merged

fix(classroom): mine=1 の shared list が空 ExpressionAttributeNames で 500#1090
smalruby3-editor-bot[bot] merged 1 commit into
feature/assignment-sharingfrom
fix/shared-assignments-mine-500

Conversation

@smalruby3-editor-bot

Copy link
Copy Markdown

Summary

PR #1080 のレビュー中に発見された prod の 500 を修正します。

症状: クラス一覧 > 課題一覧 > みんなの課題からさがす > 「自分の投稿」タグ → GET /shared-assignments?mine=1 が 500 (Internal Server Error)。投稿の有無に関係なく mine=1 は常に失敗していました。

原因: CloudWatch (prod ClassroomHandler) に ValidationException: ExpressionAttributeNames must not be emptymine=1 では KeyCondition が authorSub = :pk#status エイリアスが不要なため、属性フィルタ未指定だと ExpressionAttributeNames が空オブジェクト {} になり、DynamoDB が Query を拒否していました。

修正: マップを先に組み立て、非空のときだけキーを spread する(handler.ts の group update と同じパターン)。

Changes Made

  • infra/smalruby-classroom/lambda/handler.tshandleListSharedAssignments で空の ExpressionAttributeNames を省略
  • infra/smalruby-classroom/lambda/tests/handler-shared-assignments.test.ts — mine=1 のテストに「names が undefined であること」のアサーションを追加(モックは実 DynamoDB の空マップ拒否を再現しないため、明示的にピン留め)

Pattern audit

ExpressionAttributeNames を動的に組み立てる他の箇所(classroom update / submission update / group update / shared update)はすべて最低 1 要素を必ず持つ("No fields to update" ガードあり)か、既に条件付き spread 済み(handler.ts:2591)で、同バグはこの 1 箇所のみ。

Test Coverage

  • npx jest lambda/tests/handler-shared-assignments.test.ts — 25 passed(修正前は追加アサーションが RED)
  • npx tsc --noEmit — clean

Related Issues

EPIC #1066 / PR #1080(レビュー中の topic ブランチへの fixup)

🤖 Generated with Claude Code

…list

DynamoDB rejects an empty ExpressionAttributeNames map, so
GET /shared-assignments?mine=1 (自分の投稿タグ) always returned 500 when no
attribute filters were set — the query needs no #status alias in mine mode.
Build the map first and spread the key in only when non-empty (same pattern
as the group update at handler.ts:2591).

Found during PR #1080 review on prod (2026-07-18).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@smalruby3-editor-bot
smalruby3-editor-bot Bot merged commit 70b77b4 into feature/assignment-sharing Jul 18, 2026
13 checks passed
@smalruby3-editor-bot
smalruby3-editor-bot Bot deleted the fix/shared-assignments-mine-500 branch July 18, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants