-
-
Notifications
You must be signed in to change notification settings - Fork 599
fix: Parse.query() raises TypeError Failed to execute 'has' on 'Headers': Invalid name
when no response header
#2754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: alpha
Are you sure you want to change the base?
Conversation
🚀 Thanks for opening this pull request! |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughAdds a truthy guard before calling Response.headers.has during exposed header collection in RESTController, preventing empty-name checks. Updates test mock Headers.has to throw TypeError on empty header names, aligning behavior with browser Fetch. No public API changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant RESTController
participant Fetch as Fetch API
participant Headers
Client->>RESTController: execute request
RESTController->>Fetch: fetch(url, options)
Fetch-->>RESTController: Response (headers, body)
rect rgba(200,230,255,0.3)
note right of RESTController: Collect exposed response headers
loop for each header in exposeHeaders
alt header is non-empty
RESTController->>Headers: has(header)
Headers-->>RESTController: boolean
opt if has(header)
RESTController->>RESTController: record header value
end
else header is empty
RESTController->>RESTController: skip has() call
end
end
end
RESTController-->>Client: resolve with data
sequenceDiagram
autonumber
participant Test as Test Code
participant MockHeaders as Mock Headers.has
Test->>MockHeaders: has(headerName)
alt headerName === ""
MockHeaders-->>Test: throw TypeError("Headers.has: \"\" is an invalid header name.")
else non-empty
MockHeaders-->>Test: return headerName in headers
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)src/__tests__/test_helpers/mockFetch.js (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
See: parse-community/Parse-SDK-JS#2753 See: parse-community/Parse-SDK-JS#2754 When this is released, we will retry v7
Pull Request
Issue
Closes: #2753
Approach
When parsing response headers in RESTController, the header key check is no longer performed if there are no headers.
To ensure this issue can be detected, the unit test
mockFetch
was updated to throw an exception—just like the actual runtime—when an empty string is passed toheaders.has
.Tasks
Summary by CodeRabbit