Conversation
`should reload masterKey if ttl is set and expired` set `masterKeyTtl` to 1ms and pinned the spy to exactly two calls backed by two stubbed return values. With a 1ms TTL the cached key is stale on essentially every request, so any additional internal `loadMasterKey()` call inflated the count, exhausted the stubs and left the assertions reporting `called 4 times` and `undefined` instead of the reload the spec is about. It is a flaky failure on pull requests with unrelated diffs. Fake the spy so it always returns a usable key, and assert the property the spec is about: an expired cache is reloaded (the call count grows) and the cached value is the one produced by the last load. Verified against a local MongoDB: - the original spec fails with `Expected spy unknown to have been called 2 times. It was called 4 times.` and `Expected undefined to equal 'secondMasterKey'`; - the updated spec passes; - running the whole file, both revisions report the same unrelated flaky `server can properly sets the push support` open-connection failure, so the diff adds no new failure. Refs parse-community#10681 (item 3).
|
I will reformat the title to use the proper commit message syntax. |
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
Ready for review. Scope: item 3 of #10681. The spec no longer pins the spy to exactly two calls backed by two stubbed return values; it fakes the spy so every load produces a usable key and asserts what the spec is about — an expired cache is reloaded, and the cached value is the one from the last load. The 1ms TTL and the Checked before submitting, against a local MongoDB:
What I could not check: the rest of the suite, which needs a database on the default port that this host does not provide. The spec stays timing-sensitive by construction; what is removed is the stub exhaustion plus pinned call count the issue describes. Prepared with an AI coding agent and reviewed before submission. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe master-key TTL test now generates a distinct key for each load. After the TTL, it checks that another load occurred and that the cached key matches the latest load. ChangesMaster-key TTL test
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk: ⚪ Minimal · up to The update makes the TTL test tolerate extra internal key loads while still checking reload and cache behavior. No concrete merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Stability evidence on this head, added after the earlier runs. The updated spec was run five times in a row against a local MongoDB on the same revision: For contrast, the original spec failed on its first run in the same environment with: The reload the spec is about is still exercised — the call count grows and the cached value tracks the last load — only the pinned count and the two-value stub are gone. |
Pull Request
Issue
Related to #10681 — item 3 of the tracking list (the other items are untouched).
Approach
spec/index.spec.js→should reload masterKey if ttl is set and expiredconfigured the server withmasterKeyTtl: 1 / 1000and stubbed the spy with exactly two return values:With a 1ms TTL the cached key is stale on essentially every request, so the spec depends on exactly two internal
loadMasterKey()calls happening during the twosave()calls. Any additional load inflates the count, exhausts the two stubs, and both assertions then fail together:That is the failure the issue reports on unrelated pull requests (an
lru-cachechange and anundicilock-file bump).The spec now fakes the spy so it always produces a usable key, and asserts the property it is actually about: an expired cache is reloaded (the call count grows) and the cached value is the one produced by the last load. The 1ms TTL and the
setTimeoutare kept, so behaviour under test is unchanged.Verification
Against a local MongoDB (
mongodb-runner start, test database from the default URI):Whole file, same database, same command:
So the diff neither introduces nor hides a failure: the remaining failure is the pre-existing flaky open-connection check, and it lands on a different spec depending on the random order.
Notes and limitations, stated plainly:
spec/helper.jswas temporarily pointed at the local runner's port (the suite hardcodesmongodb://localhost:27017/...) and restored before this commit; the commit contains onlyspec/index.spec.js.Tasks
Summary by CodeRabbit