Repository navigation
fix(bench): report validator init errors on every NewView call - #2580
Merged
Merged
Conversation
AkramBitar
requested review from
Effi-S and
adecaro
and removed request for
Effi-S
October 29, 2026 12:29
The token validation benchmark built its validator inside `once.Do` but recorded the error into an `initErr` local to each `NewView` call, so only the first call could observe it. If that first init failed, `cachedValidator` stayed nil and every later call skipped the `initErr` guard and handed the view a nil validator. The real cause was lost and all subsequent requests failed inside `Call` with a misleading "validator backend is nil". Replace the `once`/`cachedValidator` globals with a `validatorCache` whose `get` returns `(*token.Validator, error)` on every call. A failure is not memoized, so a transient error does not poison the cache. The cache is a field of the factory rather than a global; its zero value works, so every existing call site is unchanged. Also switch this file to the FSC `errors` package and document the validator lifecycle. Fixes #2565 Signed-off-by: AkramBitar <akram@il.ibm.com>
Effi-S
force-pushed
the
fix-2565-validator-cache
branch
from
November 1, 2026 10:46
7a98830 to
23a3fba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The benchmark built its validator inside
once.Dobut stored the error in a variable local to eachNewViewcall, so only the first call could see it. If that first init failed, every later call skipped the error guard and got a nil validator — the real cause was lost and requests failed with a misleading "validator backend is nil".validatorCache.getnow returns the error on every call, and does not memoize failures. The cache is a field of the factory instead of a package global; its zero value works, so no call site changes.Fixes #2565