Fix recorder producing Content-Type in both content_type and headers#788
Open
worksbyfriday wants to merge 1 commit intogetsentry:masterfrom
Open
Fix recorder producing Content-Type in both content_type and headers#788worksbyfriday wants to merge 1 commit intogetsentry:masterfrom
worksbyfriday wants to merge 1 commit intogetsentry:masterfrom
Conversation
The recorder stores Content-Type in the content_type field AND in headers, causing RuntimeError when the recorded file is loaded via _add_from_file (which passes both to add(), triggering the conflict check). Fix: exclude Content-Type from the headers dict when recording, since it's already captured in the content_type field. Fixes getsentry#741 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
The recorder stores
Content-Typein both thecontent_typefield and theheadersdict. When the recorded file is loaded via_add_from_file, both are passed toadd(), which raisesRuntimeError("You cannot define both content_type and headers[Content-Type]").The fix excludes
Content-Typefrom theheadersdict when recording, since it's already captured in the dedicatedcontent_typefield.Test plan
test_recorder_excludes_content_type_from_headers— records a response withContent-Type: application/json; charset=UTF-8and verifies the YAML output hascontent_typeset but noContent-TypeinheadersFixes #741