<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>168043</bug_id>
          
          <creation_ts>2017-02-09 01:34:44 -0800</creation_ts>
          <short_desc>[Fetch API] fetch fails when undefined is passed as headers</short_desc>
          <delta_ts>2017-05-08 22:08:55 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Torjus">torjus.bjaen</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>cdumez</cc>
    
    <cc>commit-queue</cc>
    
    <cc>thomasmulhall410</cc>
    
    <cc>torjus.bjaen</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1274789</commentid>
    <comment_count>0</comment_count>
    <who name="Torjus">torjus.bjaen</who>
    <bug_when>2017-02-09 01:34:44 -0800</bug_when>
    <thetext>When explicitly passing `undefined` to the `headers` option of `fetch()`, the promise is rejected with &apos;TypeError: undefined is not an object&apos;.

To reproduce, run `fetch(&apos;/my-awesome-api&apos;, { headers: undefined })`.

Both Chrome and Firefox will accept explicitly passing `{ headers: undefined }`.
As the fetch API has been available in other browsers for quite some time now, I think passing `undefined` should be supported, as existing libraries or application may break when doesn&apos;t fall back to using a polyfill.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275325</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-02-10 08:01:41 -0800</bug_when>
    <thetext>Hi Torjus and thanks for the feedback.
Your understanding seems indeed correct.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275330</commentid>
    <comment_count>2</comment_count>
      <attachid>301160</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-02-10 08:22:40 -0800</bug_when>
    <thetext>Created attachment 301160
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275336</commentid>
    <comment_count>3</comment_count>
      <attachid>301160</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2017-02-10 08:58:34 -0800</bug_when>
    <thetext>Comment on attachment 301160
Patch

r=me

What should happen if &apos;headers&apos; is null? How about a string or a number? You should add tests for those cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275340</commentid>
    <comment_count>4</comment_count>
      <attachid>301160</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2017-02-10 09:18:04 -0800</bug_when>
    <thetext>Comment on attachment 301160
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301160&amp;action=review

&gt; Source/WebCore/Modules/fetch/FetchInternals.js:33
&gt; +    if (headersInit === @undefined)

What about null?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275383</commentid>
    <comment_count>5</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-02-10 10:32:22 -0800</bug_when>
    <thetext>We need IDL tests for all of them I guess.
Checking with Chris, null should be fine (empty header), other values should not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275390</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2017-02-10 10:36:22 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; We need IDL tests for all of them I guess.
&gt; Checking with Chris, null should be fine (empty header), other values should
&gt; not.

https://heycam.github.io/webidl/#es-union (Step 3.2.)
then
https://heycam.github.io/webidl/#es-record (Step 2)

So passing null or undefined should behave the same here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275393</commentid>
    <comment_count>7</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2017-02-10 10:37:42 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; &gt; We need IDL tests for all of them I guess.
&gt; &gt; Checking with Chris, null should be fine (empty header), other values should
&gt; &gt; not.
&gt; 
&gt; https://heycam.github.io/webidl/#es-union (Step 3.2.)
&gt; then
&gt; https://heycam.github.io/webidl/#es-record (Step 2)
&gt; 
&gt; So passing null or undefined should behave the same here.

I would expect other non-object types to throw a TypeError based on https://heycam.github.io/webidl/#es-union (Step 17)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275582</commentid>
    <comment_count>8</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-02-10 15:43:48 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; &gt; We need IDL tests for all of them I guess.
&gt; &gt; Checking with Chris, null should be fine (empty header), other values should
&gt; &gt; not.
&gt; 
&gt; https://heycam.github.io/webidl/#es-union (Step 3.2.)
&gt; then
&gt; https://heycam.github.io/webidl/#es-record (Step 2)
&gt; 
&gt; So passing null or undefined should behave the same here.

This feels a bit odd though in that case to have the same behavior.
Somehow {headers: undefined} means that there is no headers in the dictionary and we should reuse the RequestInfo headers if any.
{headers: null} might mean to create a request without any header.

Let&apos;s get more time for fetch+WebIDL spec to stabilise on that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275592</commentid>
    <comment_count>9</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-02-10 15:51:34 -0800</bug_when>
    <thetext>Landing this patch as is since it is a step in the right direction.
We will probably complement it with additional patches.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275596</commentid>
    <comment_count>10</comment_count>
      <attachid>301160</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-02-10 15:55:06 -0800</bug_when>
    <thetext>Comment on attachment 301160
Patch

Clearing flags on attachment: 301160

Committed r212162: &lt;http://trac.webkit.org/changeset/212162&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1275597</commentid>
    <comment_count>11</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-02-10 15:55:11 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1292229</commentid>
    <comment_count>12</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-03-28 17:32:23 -0700</bug_when>
    <thetext>*** Bug 169970 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1306258</commentid>
    <comment_count>13</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-05-08 22:08:55 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #8)
&gt; (In reply to comment #6)
&gt; &gt; (In reply to comment #5)
&gt; &gt; &gt; We need IDL tests for all of them I guess.
&gt; &gt; &gt; Checking with Chris, null should be fine (empty header), other values should
&gt; &gt; &gt; not.
&gt; &gt; 
&gt; &gt; https://heycam.github.io/webidl/#es-union (Step 3.2.)
&gt; &gt; then
&gt; &gt; https://heycam.github.io/webidl/#es-record (Step 2)
&gt; &gt; 
&gt; &gt; So passing null or undefined should behave the same here.

WebIDL spec has changed and we should now throw in case of null passed to a Record.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>301160</attachid>
            <date>2017-02-10 08:22:40 -0800</date>
            <delta_ts>2017-02-10 15:55:06 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-168043-20170210082014.patch</filename>
            <type>text/plain</type>
            <size>3849</size>
            <attacher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