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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26903</bug_id>
          
          <creation_ts>2014-09-25 17:00:14 +0000</creation_ts>
          <short_desc>Parameter validation errors should return SyntaxError not DataError</short_desc>
          <delta_ts>2014-10-30 23:25:06 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Web Cryptography</product>
          <component>Web Cryptography API Document</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</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>
          <dependson>25741</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Watson">watsonm</reporter>
          <assigned_to name="Mark Watson">watsonm</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>public-webcrypto</cc>
    
    <cc>sleevi</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112179</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-25 17:00:14 +0000</bug_when>
    <thetext>SyntaxError: A required parameter was missing or out-of-range
DataError: Data provided to an operation does not meet requirements

If method parameters are out-of-range this should be a SyntaxError, if something is wrong with octet string data provided to the method then this is a DataError.

Specific cases to fix:
- validation of extractable in DH import</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112187</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-25 17:58:28 +0000</bug_when>
    <thetext>Additional cases
- validation of length fields in various cases</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112194</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-09-25 20:21:05 +0000</bug_when>
    <thetext>SyntaxError should be a syntax error, no?

Out-of-range in Web IDL throws a TypeError.  It might be good to just align with that.

Alternately you could consider RangeError, and maybe even coordinating that with Web IDL changing its out-of-range handling.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112195</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-09-25 20:21:36 +0000</bug_when>
    <thetext>And note that in general parameter validation failures in Web IDL throw TypeErrors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112200</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-25 21:48:27 +0000</bug_when>
    <thetext>That may well be a good idea. I&apos;d like to hear what others think. For the moment I&apos;ll at least make the specification internally consistent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112226</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-26 00:44:46 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webcrypto-api/rev/8bdec08fdc99</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112276</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-09-26 17:39:35 +0000</bug_when>
    <thetext>Regarding TypeError for out-of-range cases. If the value is actually outside the range that is value for the data type, for example a negative integer provided for an unsigned int type, this makes sense.

But if the value is in-range for the type but invalid for some application-specific reason (e.g. key lengths that can only be one of a set of specific values) that seems like a different kind of out-of-range.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112777</commentid>
    <comment_count>7</comment_count>
    <who name="Ryan Sleevi">sleevi</who>
    <bug_when>2014-10-07 02:58:41 +0000</bug_when>
    <thetext>(In reply to Mark Watson from comment #4)
&gt; That may well be a good idea. I&apos;d like to hear what others think. For the
&gt; moment I&apos;ll at least make the specification internally consistent.

I agree with Boris that SyntaxError surprises me. DataError made some degree of sense, but it had its own set of complexity attached to it. TypeError strikes me as more internally consistent.

Or is InvalidAccessError more consistent?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112790</commentid>
    <comment_count>8</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-10-07 14:23:07 +0000</bug_when>
    <thetext>(In reply to Ryan Sleevi from comment #7)
&gt; (In reply to Mark Watson from comment #4)
&gt; &gt; That may well be a good idea. I&apos;d like to hear what others think. For the
&gt; &gt; moment I&apos;ll at least make the specification internally consistent.
&gt; 
&gt; I agree with Boris that SyntaxError surprises me.

It&apos;s not surprising it was used this way given then definition we have (see comment #0), but I think the definition is wrong. Out-of-range is not a &apos;syntax&apos; issue.

In fact I am not sure there can be any syntax problems with a method call other than missing required parameters: everything passed in is already a valid JS type and if it is not the right type this is a TypeError.

We could say &quot;missing or invalid&quot; in the SyntaxError definition just in case.

&gt; DataError made some degree
&gt; of sense, but it had its own set of complexity attached to it. TypeError
&gt; strikes me as more internally consistent.
&gt; 
&gt; Or is InvalidAccessError more consistent?

We&apos;ve used InvalidAccessError for cases where you try to use a key for something it cannot do: it doesn&apos;t have the right usage or extractable value or providing the wrong kind of public key to a DH derive.

Shall we switch to TypeError for the out-of-range cases ?

Note that this is dependent on the other discussion of whether we should switch to OperationError to give flexibility to implementations to delegate range checks to libraries that might not expose the reason for a failure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114246</commentid>
    <comment_count>9</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-10-30 16:40:43 +0000</bug_when>
    <thetext>Agreed at f2f to switch to TypeError for out-of-range cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114293</commentid>
    <comment_count>10</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2014-10-30 23:25:06 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webcrypto-api/rev/b8f161c372a5

There is one common case where SyntaxError is used which I have left as a SyntaxError. This is the case where incorrect usages are supplied. That is, recognized usage values, but incorrect for the type of key being generated, imported or unwrapped.

It doesn&apos;t seem right to call this a TypeError, since as far as the usages data type is concerned the information is correct. Please re-open if you disagree.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>