fix(issue): Handle object headers in buildRequestMarkdown#1250
Open
sentry[bot] wants to merge 1 commit into
Open
fix(issue): Handle object headers in buildRequestMarkdown#1250sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5369 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 81.78% 81.77% -0.01%
==========================================
Files 424 424 —
Lines 29452 29453 +1
Branches 19190 19192 +2
==========================================
+ Hits 24085 24084 -1
- Misses 5367 5369 +2
- Partials 1999 2001 +2Generated by Codecov Action |
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.
This PR addresses CLI-297, a
TypeError: .for is not iterableoccurring inbuildRequestMarkdownwhen processing issue request data.Problem:
The
buildRequestMarkdownfunction insrc/lib/formatters/human.tsassumed thatrequestEntry.data.headerswould always be an array of[key, value]tuples, suitable forfor...ofiteration. However, the Sentry API can sometimes return headers as a plain object (Record<string, string>), leading to aTypeErrorwhen attempting to iterate over it.Solution:
RequestEntry.data.headersinsrc/types/sentry.tshas been updated to[string, string][] | Record<string, string> | nullto accurately reflect the possible data shapes from the API.buildRequestMarkdown, a check has been added to determine ifdata.headersis an array. If it's not an array (implying it's an object),Object.entries()is used to convert the object into an array of[key, value]tuples before iteration. This ensures that thefor...ofloop can correctly process headers regardless of their original format.Fixes CLI-297
Comment
@sentry <feedback>on this PR to have Autofix iterate on the changes.