Skip to content

one_d4: treat chess.com archive 404 as indexing failure (#1360) - #1381

Merged
aaylward merged 3 commits into
mainfrom
cursor/chess-com-404-empty-month-5f43
Aug 14, 2026
Merged

one_d4: treat chess.com archive 404 as indexing failure (#1360)#1381
aaylward merged 3 commits into
mainfrom
cursor/chess-com-404-empty-month-5f43

Conversation

@aaylward

@aaylward aaylward commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Closes #1360.

Problem

ChessClient maps every chess.com 404 to Optional.empty(), and IndexWorker treated that as “no games this month,” completing the request as success. Empirically, empty months are HTTP 200 with {"games":[]}; a 404 is a missing player or an upstream failure on a listed archive.

Fix (IndexWorker only)

No ChessClient change. In the month loop:

  • Optional.empty() → archive-fetch error, throw RuntimeException, fail the request (retryable), do not upsert an empty period
  • present response with empty games → empty-month path (period row, MONTHS=empty, ARCHIVE_FETCHES=no_archive) as before

Tests

  • a404OnAnArchiveChessComListsIsAnErrorNotAnEmptyMonth
  • a200WithEmptyGamesStillRecordsAnEmptyMonthAndCompletes
  • metrics_archive404IsCountedAsErrorNotEmptyMonth
  • stubs/fakes that meant “empty month” now return an empty GamesResponse instead of Optional.empty()

Verification

  • bazel test IndexWorkerTest, IndexWorkerLifecycleTest, RequestLeaseCeilingTest, RequestLeaseOwnershipTest, IndexResponseWireTest
  • scripts/mutation-check killed both branch mutations on the new empty/404 split

Follow-up for typed client results / x-chesscom-matched: #1382.

Open in Web Open in Cursor 

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
1d4-web 4a07b1c Commit Preview URL

Branch Preview URL
Aug 14 2026, 12:37 AM

// swept (DataAvailabilityResolver reads a missing row as "gone"), and would make the
// period cache miss forever, refetching an empty archive on every request.
metrics.increment(ARCHIVE_FETCHES, Map.of("result", "error"));
throw new IllegalStateException(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISE doesn't seem quite right here

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — switched to ChessComApiException(404, …) so it matches the other non-success archive outcomes. IllegalStateException was leftover from the altitude panel preferring “any RuntimeException” over inventing a typed 404; wrong call for a wire failure ChessClient had flattened.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RTE would have been fine here too fwiw

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to plain RuntimeException.

@aaylward
aaylward marked this pull request as ready for review August 14, 2026 00:23
cursoragent and others added 3 commits August 13, 2026 20:36
…nth (#1360)

Empty months are HTTP 200 with an empty games list. ChessClient still maps
404 to Optional.empty(); IndexWorker now fails the request on that shape
instead of COMPLETE-ing it as indexed-with-zero-games.

Co-authored-by: Andy Aylward <aaylward@users.noreply.github.com>
Review: IllegalStateException mislabeled a chess.com wire failure.

Co-authored-by: Andy Aylward <aaylward@users.noreply.github.com>
Prefer a plain RTE over ChessComApiException for the Optional.empty()
failure path.

Co-authored-by: Andy Aylward <aaylward@users.noreply.github.com>
@aaylward
aaylward force-pushed the cursor/chess-com-404-empty-month-5f43 branch from 336d86f to 4a07b1c Compare August 14, 2026 00:36
@aaylward
aaylward enabled auto-merge (squash) August 14, 2026 00:36
@aaylward
aaylward merged commit 430f081 into main Aug 14, 2026
18 checks passed
@aaylward
aaylward deleted the cursor/chess-com-404-empty-month-5f43 branch August 14, 2026 00:41
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.

one_d4: a chess.com 404 is recorded as an empty month, so an upstream error completes as success

2 participants