Skip to content

fix(test): TestResolveAllowedIP_Timeout is flaky in CI #1506

Description

@Wikid82

Problem

TestResolveAllowedIP_Timeout in backend/internal/utils/url_testing_security_test.go fails intermittently in CI with Expected timeout error, got nil.

Evidence

  • Failed in Backend (Go) on release PR chore(main): release 0.44.3 #1504 (run 37572083310, job 112632740951): FAIL: internal/utils TestResolveAllowedIP_Timeout (0.00s), the only failure out of 10273 tests.
  • The same package passed on main (run 37570500238), on the PR fix(security): harden backend consistency checks #1500 branch, and locally, with identical code.
  • The test passes context.WithTimeout(ctx, 1*time.Nanosecond) and expects resolveAllowedIP(ctx, "example.com", false) to return an error. Whether the deadline is observed before the resolver returns (cached or hosts-file answer, fast local resolver) is racy, so the result depends on timing and the environment.

Severity

Medium (CI flake). It fails a required check on unrelated branches, and CLAUDE.md forbids deferring failing tests.

Suggested approach

Make it deterministic: cancel the context before the call (cancel() then call), or use a context whose deadline is already in the past, and assert errors.Is(err, context.Canceled) / DeadlineExceeded. Also check that resolveAllowedIP checks ctx.Err() up front so an already-expired context always fails, and make the final assertion a t.Errorf instead of a t.Logf so it actually guards the behavior.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

  • Status
    Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions