Skip to content

🐛 fix(git): classify HTTP status codes from typed errors and status phrases; stabilise delete-watch envtest - #459

Merged
konih merged 3 commits into
mainfrom
fix/delete-watch-envtest
Oct 10, 2026
Merged

konih merged 3 commits into
mainfrom
fix/delete-watch-envtest

Conversation

@konih

@konih konih commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Two pre-existing flakes that kept main red (not #454 regressions).

  1. Delete-watch envtest: the spec deleted its sink right after cache sync, but the controller's Watches handler is attached asynchronously afterwards; an earlier delete is never replayed, so closes stayed 0. Pre-♻️ refactor: delete the production-dead exported surface (kollect-xconsol §4 sweep 2) #454 fails 1/30, main 1/15. Fix: wait for an observed reconcile of the sink (workers start only after the handler is registered) before pooling and deleting. Mutation check: removing the Watches clause fails the real assertion after 30s.

  2. TestRunCleanupExport_gitReleaseFailureIsRetried: ClassifyExportError matched 401/503/429 as bare substrings, so a random temp-dir name containing 401 turned a transient clone error terminal. Fix: read the status from go-git's typed http.Err and from status phrases only (never digit runs in URLs, hostnames or mirror dirs); 401/403 terminal, 429/5xx transient; ErrAuthorizationFailed is auth; the CLI's 'returned error: 403' is now terminal. Table test covers team401 URL, hex mirror dir, git-503 hostname and the existing rows.

konih added 2 commits October 10, 2026 17:30
The envtest spec deleted its sink as soon as the cache synced, but the
manager attaches a controller's Watches handler asynchronously after
that. A delete landing before registration is never replayed to the
handler (late handlers only get synthetic Adds), so the spy saw zero
closes and the spec timed out. Probe with throwaway sinks until one
delete reaches the seam, then run the real assertion.
ClassifyExportError matched 401/503/429 as bare substrings, so digits in
a random temp-dir path (a missing local remote) read as an auth failure
and turned a transient clone error terminal. TestRunCleanupExport_
gitReleaseFailureIsRetried failed in CI whenever the dir name contained
401. Require a non-digit boundary around the code.
@konih konih changed the title ✅ test(controller): wait for the delete-watch handler before deleting ✅ test(controller): fix delete-watch envtest race and git status-code misclassification Oct 10, 2026
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/sink/git/errors.go 88.46% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

…hrases

Bare-substring and digit-boundary matching still misread codes inside
URLs, hostnames and hex mirror dirs (team401, git-503.example.com,
3fa401bc9e0d). Read the status from go-git's typed http.Err and from
status phrases only (status code: N, returned error: N, HTTP N, N
forbidden, (N)), classify 401/403 terminal and 429/5xx transient, and
treat ErrAuthorizationFailed as auth. The git CLI's returned error: 403
is now terminal too.

The delete-watch envtest now gates on an observed reconcile of the sink
(workers start after the Watches handler is registered) instead of probe
deletes, and no longer leaks an unused sink.
@konih konih changed the title ✅ test(controller): fix delete-watch envtest race and git status-code misclassification 🐛 fix(git): classify HTTP status codes from typed errors and status phrases; stabilise delete-watch envtest Oct 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

@konih
konih merged commit 76239b7 into main Oct 10, 2026
42 checks passed
@konih
konih deleted the fix/delete-watch-envtest branch October 10, 2026 17:01
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.

1 participant