- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 600
 
          fix: Parse.Query throws error 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
  
    fix: Parse.Query throws error when no response header
  
  #2754
              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 when collecting exposed headers, updates mock Headers.has to throw on empty header names, and adds tests ensuring AJAX resolves when access-control-expose-headers is missing or empty. No public API changes. Changes
 Sequence Diagram(s)sequenceDiagram
  autonumber
  participant Client
  participant RESTController
  participant FetchAPI as Fetch API
  participant Headers
  Client->>RESTController: execute request
  RESTController->>FetchAPI: fetch(url, options)
  FetchAPI-->>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 true
          RESTController->>RESTController: record header value
        end
      else header is empty or falsy
        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🎯 3 (Moderate) | ⏱️ ~20 minutes 
 Pre-merge checks and finishing touches✅ Passed checks (3 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
 🧰 Additional context used🧬 Code graph analysis (1)src/__tests__/test_helpers/mockFetch.js (1)
 🔇 Additional comments (1)
 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encountered this also
| 
           @Niccari could you add a test?  | 
    
          Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@           Coverage Diff           @@
##            alpha    #2754   +/-   ##
=======================================
  Coverage   99.88%   99.88%           
=======================================
  Files          64       64           
  Lines        6220     6220           
  Branches     1488     1472   -16     
=======================================
  Hits         6213     6213           
  Misses          7        7           ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
  | 
    
| has: header => headers[header] !== undefined, | ||
| has: header => { | ||
| if (header === '') { | ||
| throw new TypeError('Headers.has: "" is an invalid header name.'); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new TypeError('Headers.has: "" is an invalid header name.'); | |
| throw new TypeError('Invalid empty header name.'); | 
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Failed to execute 'has' on 'Headers': Invalid name when no response headerParse.Query throws error when no response header
      | 
           Looks good, but waiting for more details in #2753 (comment) for proper changelog entry.  | 
    
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
| 
           Thanks for the PR! Waiting for CI to pass...  | 
    
## [7.0.2-alpha.1](7.0.1...7.0.2-alpha.1) (2025-10-25) ### Bug Fixes * `Parse.Query` throws error when no response header ([#2754](#2754)) ([492de3e](492de3e))
| 
           🎉 This change has been released in version 7.0.2-alpha.1  | 
    
## [7.0.2](7.0.1...7.0.2) (2025-10-25) ### Bug Fixes * `Parse.Query` throws error when no response header ([#2754](#2754)) ([492de3e](492de3e))
| 
           🎉 This change has been released in version 7.0.2  | 
    
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
mockFetchwas updated to throw an exception—just like the actual runtime—when an empty string is passed toheaders.has.Tasks
Summary by CodeRabbit
Bug Fixes
Tests