a2n-seattle / a2n-seattle/rms-app

return-group.spec.ts flaky: History Scan doesn't reliably surface recent entries

Aberta
#370 2 comentários 0 reações 0 responsáveis Ver no GitHub
bug priority-low
Linguagem predominante
TypeScript
Estrelas
1
Forks
1
Merge médio
27min
PRs com merge (30d)
4

Descrição

## Problem

`web/e2e/return-group.spec.ts`'s final assertion (a returned item's condition note shows up on the dashboard's History tab) fails intermittently in CI, timing out even with a 45s/5s-interval poll budget.

## Root cause

Confirmed via direct DynamoDB inspection during GH-356's e2e-flakiness work: the write path is correct — the condition note is reliably persisted to `history-alpha` (`ItemTable.createHistoryEntry`). The failure is purely on the read side:

- `ListHistory` (`ts-code/src/api/ListHistory.ts`) defaults to a 25-item page (`DEFAULT_PAGE_SIZE = 25`), read via an unordered `Scan+FilterExpression` (`scanUntilLimit`).
- DynamoDB `Scan` does not return items in any guaranteed order (not chronological).
- The shared e2e fixture item (`RMS_TEST_ITEM_ID`) has accumulated a very large number of history entries from extensive repeated CI runs, so a freshly-written entry has a low chance of landing in the first unordered 25-item page the dashboard's History tab reads.
- Separately, `history-alpha` (like the rest of this repo's tables) is provisioned at 1 RCU/1 WCU (see root `CLAUDE.md`), so repeated Scans against a now-large table intermittently throttle (`ProvisionedThroughputExceededException`), compounding the problem.

## Suggested fix directions (not decided)

- Add a secondary sort/index so `ListHistory` can return newest-first instead of arbitrary Scan order (would need a GSI on `history-alpha`, keyed by `borrower`/`itemId` + `timestamp` — today there's no GSI on this table, only base-table Scans).
- And/or: clean up `history-alpha`'s accumulated entries for the shared e2e fixture item (a one-off maintenance script, paced per this repo's 1 WCU-table write-pacing convention — see `ts-code/scripts/migrate-353-stable-ids.ts` for the established pattern) so the working set stays small enough for a first-page Scan to reliably include recent writes.
- Do not fix this by raising table capacity — the user has flagged that account-wide DynamoDB capacity (currently 7 RCU/7 WCU total across 7 tables, out of the 25/25 free-tier ceiling) needs to stay low headroom-wise for `beta`/`master` environments planned later (see "Branching and environment promotion" in root `CLAUDE.md`).

## Context

Found while stabilizing e2e CI for GH-356 (PR #369, merged via admin override past this one flaky check — every other check, including the rest of the e2e suite, unit tests, coverage, and CodeQL, was green). No code changes have been made for this issue yet.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

O teste que está falhando é web/e2e/return-group.spec.ts. Examine a tabela DynamoDB history-alpha e a API ListHistory em ts-code/src/api/ListHistory.ts. Entenda a lógica de scanUntilLimit e a capacidade provisionada da tabela. A correção provavelmente envolve adicionar um GSI para ordenação cronológica ou limpar os dados de teste, seguindo os padrões em ts-code/scripts/migrate-353-stable-ids.ts. Verifique a correção executando o teste e2e e confirmando que novas entradas do histórico aparecem na aba History do dashboard.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
aws
Domínio
backend, databases, testing-qa
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Pouca atividade
Clareza
Claramente especificada
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.