fix(cache): tolerate list bodies from JSON-RPC batch (rpc_batch post-payment crash)#17
Merged
Conversation
…crashed post-payment on rpc_batch
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.
What
Follow-up to #16.
rpc_batch()sends a JSON-RPC list body through_request_with_payment_raw, which on the paid path callssave_to_cache(endpoint, body, ...). Both_readable_filename(body.get("query")) and the cost-log model lookup (body.get("model")) assume a dict — so every paidrpc_batch()call raisedAttributeErrorafter the USDC settlement, in both sync and async Solana clients.Fix
_readable_filename: treat non-dict bodies as unlabelable (empty label).save_to_cache: only pullmodelfrom the body when it is a dict.Validation
save_to_cache("/v1/rpc/eth", [<batch>], ...)crashed before, passes now; dict-body labeling unchanged.pytest tests/unit(271 passed) on the branch.