Skip to content

fix faling tests

75918ab
Select commit
Loading
Failed to load commit list.
Open

[TT-6075] Create option to populate the X-ratelimit headers from rate limits rather than quotas #7730

fix faling tests
75918ab
Select commit
Loading
Failed to load commit list.
probelabs / Visor: quality failed Feb 19, 2026 in 1m 6s

🚨 Check Failed

quality check failed because fail_if condition was met.

Details

📊 Summary

  • Total Issues: 5
  • Error Issues: 2
  • Warning Issues: 3

🔍 Failure Condition Results

Failed Conditions

  • global_fail_if: output.issues && output.issues.some(i => i.severity === 'critical' || i.severity === 'error')
    • Severity: ❌ error

Issues by Category

Logic (3)

  • gateway/session_manager_test.go:524 - The test TestSessionLimiter/limitRedis contains an assertion with a 'magic number' and confusing comments, which harms test integrity. The assertion assert.True(t, state.Reset == 0, ...) for the first call to the rate limiter is not intuitive for a sliding window algorithm and lacks justification. Furthermore, a comment on line 527 incorrectly states a request is "blocked" while the corresponding assertion on line 528 checks that it is not blocked (assert.False(t, block)). Tests should have clear, justifiable assertions and accurate comments to be reliable and maintainable.
  • ⚠️ gateway/session_manager.go:283 - The new rate-limiting logic introduced in ForwardMessage and its helper newRateLimitChecker has insufficient test coverage. The quality gate failed with 70.2% coverage on new code, below the 80% threshold. The existing new tests cover sentinel and Redis rolling limiter paths, but they do not appear to cover other strategies, such as the DRL (Distributed Rate Limiting) path or the generic limiter.Func path. This lack of coverage for all supported rate-limiting mechanisms reduces confidence in the feature's reliability.
  • system:0 - Global failure condition met: output.issues && output.issues.some(i => i.severity === 'critical' || i.severity === 'error')

Architecture (1)

  • ⚠️ gateway/server.go:1609 - The limitHeaderFactory is initialized in initSystem, but it is also initialized earlier in the NewGateway constructor (line 277). This duplication, highlighted by the developer's own comment // !!! review bootstrap process and NewGateway(); this process is broken :/, points to a flawed application startup and configuration lifecycle. This can lead to unpredictable behavior and makes the code harder to maintain.

Style (1)

  • ⚠️ gateway/mw_rate_limiting.go:110 - In the ProcessRequest function, the limitHeaderFactory is called twice to create a header sender. A limitHeader variable is created on line 74, but it is not reused. Instead, a new headerSender variable is created on line 110 for the throttling logic. This is a violation of the DRY (Don't Repeat Yourself) principle.

Powered by Visor from Probelabs

💡 TIP: You can chat with Visor using /visor ask <your question>

Annotations

Check failure on line 531 in gateway/session_manager_test.go

See this annotation in the file changed.

@probelabs probelabs / Visor: quality

logic Issue

The test `TestSessionLimiter/limitRedis` contains an assertion with a 'magic number' and confusing comments, which harms test integrity. The assertion `assert.True(t, state.Reset == 0, ...)` for the first call to the rate limiter is not intuitive for a sliding window algorithm and lacks justification. Furthermore, a comment on line 527 incorrectly states a request is "blocked" while the corresponding assertion on line 528 checks that it is not blocked (`assert.False(t, block)`). Tests should have clear, justifiable assertions and accurate comments to be reliable and maintainable.
Raw output
Replace the magic number `0` with a calculated or well-explained expected value for the reset time. Correct the misleading comments to accurately reflect the behavior being tested.

Check warning on line 1609 in gateway/server.go

See this annotation in the file changed.

@probelabs probelabs / Visor: quality

architecture Issue

The `limitHeaderFactory` is initialized in `initSystem`, but it is also initialized earlier in the `NewGateway` constructor (line 277). This duplication, highlighted by the developer's own comment `// !!! review bootstrap process and NewGateway(); this process is broken :/`, points to a flawed application startup and configuration lifecycle. This can lead to unpredictable behavior and makes the code harder to maintain.
Raw output
Refactor the gateway initialization process to ensure components like `limitHeaderFactory` are initialized only once. The configuration should be loaded and passed consistently, avoiding re-initialization in different lifecycle hooks.

Check warning on line 323 in gateway/session_manager.go

See this annotation in the file changed.

@probelabs probelabs / Visor: quality

logic Issue

The new rate-limiting logic introduced in `ForwardMessage` and its helper `newRateLimitChecker` has insufficient test coverage. The quality gate failed with 70.2% coverage on new code, below the 80% threshold. The existing new tests cover sentinel and Redis rolling limiter paths, but they do not appear to cover other strategies, such as the DRL (Distributed Rate Limiting) path or the generic `limiter.Func` path. This lack of coverage for all supported rate-limiting mechanisms reduces confidence in the feature's reliability.
Raw output
Add unit tests to cover the remaining branches within `newRateLimitChecker`, specifically for the DRL code path and the generic `limiter.Func` path, to meet the project's test coverage requirements.

Check warning on line 110 in gateway/mw_rate_limiting.go

See this annotation in the file changed.

@probelabs probelabs / Visor: quality

style Issue

In the `ProcessRequest` function, the `limitHeaderFactory` is called twice to create a header sender. A `limitHeader` variable is created on line 74, but it is not reused. Instead, a new `headerSender` variable is created on line 110 for the throttling logic. This is a violation of the DRY (Don't Repeat Yourself) principle.
Raw output
Remove the second call to `k.Gw.limitHeaderFactory(w.Header())` on line 110 and reuse the `limitHeader` variable that was created on line 74.