Skip to content

test(chat_files): pin lazy-heal mint contract for both Upload and Download - #2370

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
auto/lazy-heal-test-coverage
Apr 30, 2026
Merged

HongmingWang-Rabbit merged 1 commit into
stagingfrom
auto/lazy-heal-test-coverage

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

The 2026-04-30 lazy-heal fix in `chat_files.go` (PR #2366) attempts to mint `platform_inbound_secret` on miss so legacy workspaces self-heal without requiring destructive reprovision.

The pre-existing `TestChatUpload_NoInboundSecret` + `TestChatDownload_NoInboundSecret` tests asserted the 503 response shape but did NOT pin that the mint UPDATE actually fires — they happened to exercise the mint-failure branch (sqlmock unmatched UPDATE = err = "Failed to mint" code path returns 503 with "RFC #2312" detail, which still passed the original assertions).

A regression that skipped the lazy-heal mint entirely, inverted the success/failure branches, or moved the mint elsewhere would not fail those tests.

Changes

Replaced each of the two existing tests with a pair pinning both branches:

  • `TestChatUpload_NoInboundSecret_LazyHeal` — mocks the UPDATE successfully; asserts `sqlmock.ExpectationsWereMet` (mint MUST run) + body contains "retry" + "30" (success branch).
  • `TestChatUpload_NoInboundSecret_LazyHealFailure` — mocks the UPDATE to fail; asserts body contains "Reprovision" (failure branch).
  • Same pair for the Download handler.

Independent code paths into `ReadPlatformInboundSecret` mean each handler gets its own test — a partial regression that healed Upload but skipped Download is now a test failure, not a quiet ship.

Test plan

  • All 4 tests pass: `go test ./internal/handlers/ -run TestChat\(Upload\|Download\)_NoInboundSecret`
  • Full module green: `go test ./...`
  • Verified pre-fix tests passed accidentally on the failure branch (without the new `ExpectExec` mock, the lazy-heal mint failed and the test still passed)

🤖 Generated with Claude Code

…nload

The 2026-04-30 lazy-heal fix in chat_files.go (PR #2366) ATTEMPTS to
mint platform_inbound_secret on miss so legacy workspaces self-heal
without requiring destructive reprovision. The pre-existing
TestChatUpload_NoInboundSecret + TestChatDownload_NoInboundSecret
tests asserted the 503 response shape but did NOT pin that the mint
UPDATE actually fires — they happened to exercise the mint-failure
branch (sqlmock unmatched UPDATE = error = "Failed to mint" code path
returns 503 with "RFC #2312" detail, which still passed the original
assertions).

This means a regression that:
  - skipped the lazy-heal mint entirely
  - inverted the success/failure response branches
  - moved the mint to a different code path

would not fail those tests.

Fix:

  - TestChatUpload_NoInboundSecret_LazyHeal: mock the UPDATE
    successfully; assert sqlmock.ExpectationsWereMet (mint MUST run)
    + body contains "retry" + "30" (success branch).
  - TestChatUpload_NoInboundSecret_LazyHealFailure: mock the UPDATE
    to fail; assert body contains "Reprovision" (failure branch).
  - Same pair for the Download handler — independent code path means
    independent test.

Pins both branches of both handlers (4 tests) so future drift trips
the gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit added this pull request to the merge queue Apr 30, 2026
Merged via the queue into staging with commit ab6bcc0 Apr 30, 2026
18 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the auto/lazy-heal-test-coverage branch April 30, 2026 09:45
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…RC)

Per CR2 RC: the status-reaper observability fix was complete, but the
merge-queue exception handlers in main() still returned 0 on ApiError,
URLError, and TimeoutError. This hid persistent infra issues from
operators — the cron stayed green while the queue could not evaluate
merge state.

Now all three handlers return 1 so the cron job surfaces red and
operators are paged to investigate.

Diff-proof: 52/52 gitea-merge-queue tests pass.

Refs: core#2370, CR2 RC.
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…ability hardening' (#2370) from fix/status-reaper-observability into main

2 genuine officials current head + required-green, mergeable — direct-merge (avoid rebase-churn approval-dismissal). CTO diff-reviewed (efficiency unblock).
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