Repository navigation
fix(client): make cacheToolMetadata atomic on v1.x - #3093
kanchingyg wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 1c161e4 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
Read the diff against the test it adds. The swap-after-build is the right shape for a throw in Two consequences of keeping the previous cache that the new test pins without saying so:
Also the changeset bot reports no changeset; a patch entry like the one in #3091 would be enough. |
|
Thanks for the review @arhancanli!
|
|
Thanks, that settles both for me. If #2614 asks for "previous complete generation unchanged", then all-or-nothing is the contract, and the cache is always one complete catalog the server really returned, never a mix of old and new. And a manual One thing the rejected refresh leaves open: the caller gets the compile error from |
|
Keeping the original throw untouched matches |
|
Fair, leaving the throw untouched keeps this PR to the one contract in #2614, and I would not change the message shape here either. The cost is that |
|
It was only caution around changing the thrown error on \�1.x, not a known caller matching on that text; in fact, because \createDefaultAjvInstance()\ sets \�alidateSchema: false, \Ajv.compile()\ throws \ ype must be JSONType or JSONType[]: not-a-json-schema-type\ directly from codegen without a schema path. I tightened the \expect(client.listTools()).rejects.toThrow(/^type must be JSONType or JSONType[]: not-a-json-schema-type$/)\ assertion in the test to pin that exact message as suggested. |
|
That pins it well: the anchored For the follow-up: would you attach the tool name when |
84b6077 to
c21901a
Compare
|
Attaching it inside |
|
Agreed, the loop is the natural place, and it keeps the atomic part intact as long as the wrapper rethrows before the swap of the staged map, so a failed tool still leaves the previous cache untouched. A test for that ordering (call listTools() once with good schemas, then once with one bad schema, and assert the first result is still served) would pin the atomicity and the tool-name follow-up together. One thing to check before choosing |
…cheToolMetadata loop
|
Follow-up for @arhancanli: |
|
Read 1c161e4. The shape now matches what I asked for: the original One test detail: A design question for you or the maintainers: with this change, one tool with a bad |
Fixes #2614
Backports
d9ff1b3c1d7e25198b062ab33769262bf533eb1btov1.x.cacheToolMetadatapreviously cleared_cachedToolOutputValidators,_cachedKnownTaskTools, and_cachedRequiredTaskToolsbefore iterating overtools. IfgetValidator(tool.outputSchema)threw on a malformed schema midway through the loop, the client's cached tool metadata was left partially populated.This change builds the map and sets in local variables first and swaps them onto the instance only after all tool schemas compile.