fix: Skip reserved attribute names when loading a resource - #579
Open
razor-x wants to merge 1 commit into
Open
Conversation
BaseResource stored every response key as an instance variable with no reserved-name check, so a field named data or client overwrote the resource's own data hash or the Faraday client. An action attempt whose response carried a client field lost the client its next poll needed. Leave the data and client keys in the data hash without assigning them as attributes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SQW83gyXeUG61RDrHEky97
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.
Problem
SDK audit finding M10 (first part).
BaseResource#process_data_attributessets an instance variable for every response key with no reserved-name guard, so an API field nameddataorclientclobbers the resource's own@datahash or its Faraday client. The audit verified theclientcase includes the client a later action-attempt poll needs.Fix
dataandclientare never assigned as attributes. They stay readable throughresource.data["client"], andresource.client/resource.datakeep meaning what the SDK defines them to mean. Invalid Ruby identifiers were already skipped this way.Tests
spec/resources/base_resource_spec.rb: adatafield leavesresource.dataas the full response hash, aclientfield leaves the injected client in place both on construction and throughupdate_from_responseon an action attempt.Revert-check against
main: 3 failures,resource.databecame1andresource.clientbecame the string from the response.🤖 Generated with Claude Code
https://claude.ai/code/session_01SQW83gyXeUG61RDrHEky97
Generated by Claude Code