Skip to content

Conversation

mldangelo
Copy link
Member

Summary

  • Add x-promptfoo-silent header to update check API requests to suppress ugly error logging
  • Fixes verbose stack traces appearing when version check APIs timeout
  • Update corresponding test expectations

Test plan

  • Manually tested timeout scenario - no more ugly errors
  • All existing update tests pass
  • Linting and formatting checks pass

Before

Error in fetch: {
  "stack": "AbortError: This operation was aborted\n    at node:internal/deps/undici/undici:13502:13..."
} AbortError: This operation was aborted

After

Clean output with no error logging when update checks timeout (as intended).

Add x-promptfoo-silent header to update check API requests to prevent
ugly error messages from appearing when network timeouts occur during
version checks. These are non-critical operations that should fail silently.

Update test expectations to match the new headers parameter.
Copy link
Contributor

use-tusk bot commented Sep 26, 2025

⏩ No test execution environment matched (037bdaa) View output ↗


View check history

Commit Status Output Created (UTC)
037bdaa ⏩ No test execution environment matched Output Sep 26, 2025 1:25PM

View output in GitHub ↗

Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

📝 Walkthrough

Walkthrough

The change updates two functions in src/updates.ts to include a headers object { 'x-promptfoo-silent': 'true' } in fetchWithTimeout calls for getLatestVersion and getModelAuditLatestVersion. URLs, timeouts, return types, and control flow remain unchanged, including error handling (throw on non-ok for getLatestVersion; return null for getModelAuditLatestVersion). Corresponding tests in test/updates.test.ts are adjusted to expect the headers argument instead of an empty object. No public APIs or exported declarations are modified.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly describes the primary change of suppressing verbose error logging for update check timeouts through the added silent header. It uses concise and specific language that communicates the intent without including unnecessary details.
Description Check ✅ Passed The description directly outlines the addition of the x-promptfoo-silent header, the suppression of verbose stack traces on timeouts, and the corresponding test updates, all of which match the changeset. It also provides a clear test plan and before/after examples that confirm its relevance to the code modifications.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/suppress-ugly-timeout-errors-in-update-check

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30501fb and 037bdaa.

📒 Files selected for processing (2)
  • src/updates.ts (2 hunks)
  • test/updates.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/gh-cli-workflow.mdc)

Prefer not to introduce new TypeScript types; use existing interfaces whenever possible

**/*.{ts,tsx}: Follow consistent import order (Biome will handle sorting)
Use consistent curly braces for all control statements
Prefer const over let; avoid var
Use object shorthand syntax whenever possible
Use async/await for asynchronous code
Use consistent error handling with proper type checks

Files:

  • src/updates.ts
  • test/updates.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/gh-cli-workflow.mdc)

Avoid disabling or skipping tests unless absolutely necessary and documented

Files:

  • test/updates.test.ts
test/**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/jest.mdc)

test/**/*.{test,spec}.ts: Mock as few functions as possible to keep tests realistic
Never increase the function timeout - fix the test instead
Organize tests in descriptive describe and it blocks
Prefer assertions on entire objects rather than individual keys when writing expectations
Clean up after tests to prevent side effects (e.g., use afterEach(() => { jest.resetAllMocks(); }))
Run tests with --randomize flag to ensure your mocks setup and teardown don't affect other tests
Use Jest's mocking utilities rather than complex custom mocks
Prefer shallow mocking over deep mocking
Mock external dependencies but not the code being tested
Reset mocks between tests to prevent test pollution
For database tests, use in-memory instances or proper test fixtures
Test both success and error cases for each provider
Mock API responses to avoid external dependencies in tests
Validate that provider options are properly passed to the underlying service
Test error handling and edge cases (rate limits, timeouts, etc.)
Ensure provider caching behaves as expected
Always include both --coverage and --randomize flags when running tests
Run tests in a single pass (no watch mode for CI)
Ensure all tests are independent and can run in any order
Clean up any test data or mocks after each test

Files:

  • test/updates.test.ts
test/**/*.{test.ts,test.tsx,spec.ts,spec.tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Follow Jest best practices with describe/it blocks in tests

Files:

  • test/updates.test.ts
🧬 Code graph analysis (1)
src/updates.ts (1)
src/util/fetch/index.ts (1)
  • fetchWithTimeout (187-213)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Redteam (Production API)
  • GitHub Check: Test on Node 22.x and windows-latest
  • GitHub Check: Test on Node 22.x and macOS-latest
  • GitHub Check: Test on Node 24.x and windows-latest
  • GitHub Check: Redteam (Staging API)
  • GitHub Check: Test on Node 20.x and windows-latest
  • GitHub Check: webui tests
🔇 Additional comments (3)
test/updates.test.ts (1)

113-116: Updated expectation covers new silent header

Glad to see the mock now asserts the x-promptfoo-silent header, keeping the test aligned with the production request shape.

src/updates.ts (2)

13-19: Silent header addition looks correct

Passing the { 'x-promptfoo-silent': 'true' } header through fetchWithTimeout keeps the timeout untouched while suppressing noisy logs.


58-64: Consistent header propagation for model audit check

Mirroring the silent header here ensures both update paths get the same logging behavior without altering control flow.


Comment @coderabbitai help to get the list of available commands and usage tips.

@mldangelo mldangelo merged commit aa1e84a into main Sep 28, 2025
55 of 56 checks passed
@mldangelo mldangelo deleted the fix/suppress-ugly-timeout-errors-in-update-check branch September 28, 2025 19:32
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