fix: router @include variable fails with "not provided" on repeated requests (ENG-9772)#3045
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdds a ChangesNormalization cache variable removal fix
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Router image scan passed✅ No security vulnerabilities found in image: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3045 +/- ##
==========================================
+ Coverage 61.46% 61.47% +0.01%
==========================================
Files 261 261
Lines 30596 30615 +19
==========================================
+ Hits 18805 18820 +15
- Misses 10277 10280 +3
- Partials 1514 1515 +1
🚀 New features to boost your workflow:
|
…ith-not-provided-on-repeated
Expose Router.WaitForCacheWrites (backed by the existing graphMux waitForCaches) and a testenv helper so tests can deterministically observe async normalization cache writes.
…vided-on-repeated' of github.com:wundergraph/cosmo into sam/eng-9772-router-include-variable-fails-with-not-provided-on-repeated
…ith-not-provided-on-repeated
Motivation and Context
Fixes ENG-9772: an operation whose Boolean variable is used both as a field argument and in a
@skip/@includedirective succeeds on the first request, then fails on every subsequent identical request with:Root cause
normalizeNonPersistedOperationunconditionally deleted every skip/include variable from the request variables. The cached operation still declares the dual-use variable asBoolean!, so validation fails.The first request misses the cache and succeeds; ristretto's
Setis buffered, so the entry lands shortly after and every subsequent identical request hits the cache and fails until the router restarts.Fix
On cache miss, record which skip/include variables normalization actually removed (i.e. are no longer declared in the normalized operation) and store that list in the
NormalizationCacheEntry. On cache hit, delete only those from the request variables, keeping dual-use variables intact.The persisted-operation cache path is not affected: its cache key includes the skip/include variable values, so a dual-use variable stays consistent between key and entry.
Checklist
TestNormalizationCacheHitWithIncludeVariableAlsoUsedAsArgumentfails without the fix)Summary by CodeRabbit
@includedirective return consistent results from cache.