<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version  (Ruby 3.1.2) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-amsuess-core-pd-body-error-position-01" category="info" version="3">
  <!-- xml2rfc v2v3 conversion 3.16.0 -->
  <front>
    <title>Concise Problem Details: Body Error Position</title>
    <seriesInfo name="Internet-Draft" value="draft-amsuess-core-pd-body-error-position-01"/>
    <author initials="C." surname="Amsüss" fullname="Christian Amsüss">
      <organization/>
      <address>
        <postal>
          <country>Austria</country>
        </postal>
        <email>christian@amsuess.com</email>
      </address>
    </author>
    <date year="2023" month="February" day="18"/>
    <workgroup>CoRE</workgroup>
    <abstract>
      <t>This defines a single standard problem detail for use with the Concise Problem Details format:
Request Body Error Position.
Using this detail,
the server can point at the position inside the client's request body
that induced the error.</t>
    </abstract>
    <note removeInRFC="true">
      <name>Discussion Venues</name>
      <t>Discussion of this document takes place on the
    Constrained RESTful Environments Working Group mailing list (core@ietf.org),
    which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/core/"/>.</t>
      <t>Source for this draft and an issue tracker can be found at
    <eref target="https://gitlab.com/chrysn/pd-body-error-position"/>.</t>
    </note>
  </front>
  <middle>
    <section anchor="introduction">
      <name>Introduction</name>
      <t>Concise Problem Details for CoAP APIs <xref target="RFC9290"/> describes
how a server can provide details about an error processing a client request,
and how to extend these error messages.
This document uses that extension mechanism and adds the Request Body Error Position detail.</t>
      <section anchor="terminology">
        <name>Terminology</name>
        <t>The description of the problem detail uses the term "body"
as defined in <xref target="RFC7959"/>.</t>
      </section>
      <section anchor="document-lifecycle">
        <name>Document lifecycle</name>
        <t>Registering a standard problem detail merely requires a specification,
not an RFC (let alone of a particular track),
and has been performed based on version -00 of this document.</t>
        <t>Publication as an RFC has not been pursued in -00, nor is it at the time of writing.
It will expire as an Inetnet Draft,
but nonetheless be usable as the permanent reference for the IANA registration.</t>
        <t>Should a need for further development or a more official publication arise,
the document may be picked up again at a later time.
For example, that might be done in the style of <xref target="I-D.bormann-cbor-notable-tags"/>.</t>
      </section>
    </section>
    <section anchor="request-body-error-position">
      <name>Request Body Error Position</name>
      <t>The Request Body Error Position problem detail indicates that
the error described by the Concise Problem Details response resulted from processing the request body.
The numeric value indicates a byte position inside that body that corresponds to the error.
The precise error position for invalid data may vary by implementation --
for example,
if a numeric value inside a CBOR (<xref target="STD94"/>) item exceeds the expected range,
it may indicate the number's initial byte
(typically if the implementation doesn't even implement the indicated argument size)
or the argument
(if it implements it).</t>
      <t>When the request's content format indicated a non-identity content coding,
the offset points into the uncompressed body.
Consequently, this error detail is not suitable for pointing out errors that occur during uncompressing.</t>
      <t>The main envisioned use of this option is
for the client to highlight
or back-annotate (eg. to counteract minification, or to display it on some diagnostic notation)
the erroneous item in the request body for a human author.</t>
    </section>
    <section anchor="usage-example">
      <name>Usage example</name>
      <t>The figures in this section illustrate a CoAP <xref target="RFC7252"/> message exchange using CBOR <xref target="STD94"/> bodies,
and a hypothetical CoAP tool's output that utilizes this error detail.</t>
      <figure>
        <name>Messages exchanged between client and server</name>
        <artwork><![CDATA[
Req: FETCH coap://example.com/alpha/archive
Content-Format: 60 (application/cbor)
Payload:
  A2071A000123A0182C192118
Payload (diagnostic notation):
  {7: 74656, 44: 8472}

Res: 4.00 Bad Request
Content-Format: 257 (application/concise-problem-details+cbor)
Payload:
  A22071556E6B6E6F776E207175657279206B6579381808
Payload (diagnostic notation):
  {
    / title /                        -1: "Unknown query key",
    / request-body-error-position / -25: 8
  }
]]></artwork>
      </figure>
      <figure>
        <name>Output of a hypothetical CoAP client that utilizes the Request Body Error Position detail</name>
        <artwork><![CDATA[
$ coap post coap://example.com/alpha/archive cbor '{7: 74656, 44: 8472}'
Error: Bad Request: Unknown query key
{7: 74656, 44: 8472}
           ^^ The server indicated that the error occurred here.
]]></artwork>
      </figure>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>Producing a Request Body Error Position detail
gives the client some information about the internal workings of the server.
If application designers intend to minimize the amount of information obtainable about the server,
they need to weigh that goal against usability,
and may prefer not to expose this (or any other) detail.</t>
      <t>The Request Body Error Position detail can be used by malicious clients
to explore the borders of acceptable content.
This can be mitigated by limiting this (or other) details to suitably authorized users,
or, where possible, only parsing data from trusted sources in the first place.</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA considerations</name>
      <t>A new entry has been assigned in the "Standard Problem Detail Keys" subregistry
of the "Constrained RESTful Environments (CoRE) Parameters" registry.</t>
      <dl>
        <dt>Key value:</dt>
        <dd>
          <t>The value -25 is suggested</t>
        </dd>
        <dt>Name:</dt>
        <dd>
          <t>request-body-error-position</t>
        </dd>
        <dt>CDDL type:</dt>
        <dd>
          <t>uint</t>
        </dd>
        <dt>Brief description:</dt>
        <dd>
          <t>Byte index inside the request body at which the error became apparent</t>
        </dd>
        <dt>Reference:</dt>
        <dd>
          <t>This document</t>
        </dd>
        <dt>Change controller:</dt>
        <dd>
          <t>IETF CoRE working group</t>
        </dd>
      </dl>
    </section>
    <section anchor="acknowledgements">
      <name>Acknowledgements</name>
      <t>Michael Richardson provided good input for the Securitiy Considerations.</t>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="RFC9290">
          <front>
            <title>Concise Problem Details for Constrained Application Protocol (CoAP) APIs</title>
            <author fullname="T. Fossati" initials="T." surname="Fossati">
              <organization/>
            </author>
            <author fullname="C. Bormann" initials="C." surname="Bormann">
              <organization/>
            </author>
            <date month="October" year="2022"/>
            <abstract>
              <t>This document defines a concise "problem detail" as a way to carry machine-readable details of errors in a Representational State Transfer (REST) response to avoid the need to define new error response formats for REST APIs for constrained environments. The format is inspired by, but intended to be more concise than, the problem details for HTTP APIs defined in RFC 7807.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="9290"/>
          <seriesInfo name="DOI" value="10.17487/RFC9290"/>
        </reference>
        <reference anchor="RFC7959">
          <front>
            <title>Block-Wise Transfers in the Constrained Application Protocol (CoAP)</title>
            <author fullname="C. Bormann" initials="C." surname="Bormann">
              <organization/>
            </author>
            <author fullname="Z. Shelby" initials="Z." role="editor" surname="Shelby">
              <organization/>
            </author>
            <date month="August" year="2016"/>
            <abstract>
              <t>The Constrained Application Protocol (CoAP) is a RESTful transfer protocol for constrained nodes and networks.  Basic CoAP messages work well for small payloads from sensors and actuators; however, applications will need to transfer larger payloads occasionally -- for instance, for firmware updates.  In contrast to HTTP, where TCP does the grunt work of segmenting and resequencing, CoAP is based on datagram transports such as UDP or Datagram Transport Layer Security (DTLS).  These transports only offer fragmentation, which is even more problematic in constrained nodes and networks, limiting the maximum size of resource representations that can practically be transferred.</t>
              <t>Instead of relying on IP fragmentation, this specification extends basic CoAP with a pair of "Block" options for transferring multiple blocks of information from a resource representation in multiple request-response pairs.  In many important cases, the Block options enable a server to be truly stateless: the server can handle each block transfer separately, with no need for a connection setup or other server-side memory of previous block transfers.  Essentially, the Block options provide a minimal way to transfer larger representations in a block-wise fashion.</t>
              <t>A CoAP implementation that does not support these options generally is limited in the size of the representations that can be exchanged, so there is an expectation that the Block options will be widely used in CoAP implementations.  Therefore, this specification updates RFC 7252.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="7959"/>
          <seriesInfo name="DOI" value="10.17487/RFC7959"/>
        </reference>
      </references>
      <references>
        <name>Informative References</name>
        <referencegroup anchor="STD94">
          <reference anchor="RFC8949">
            <front>
              <title>Concise Binary Object Representation (CBOR)</title>
              <author fullname="C. Bormann" initials="C." surname="Bormann"/>
              <author fullname="P. Hoffman" initials="P." surname="Hoffman"/>
              <date month="December" year="2020"/>
              <abstract>
                <t>The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely small code size, fairly small message size, and extensibility without the need for version negotiation. These design goals make it different from earlier binary serializations such as ASN.1 and MessagePack.</t>
                <t>This document obsoletes RFC 7049, providing editorial improvements, new details, and errata fixes while keeping full compatibility with the interchange format of RFC 7049. It does not create a new version of the format.</t>
              </abstract>
            </front>
            <seriesInfo name="STD" value="94"/>
            <seriesInfo name="RFC" value="8949"/>
            <seriesInfo name="DOI" value="10.17487/RFC8949"/>
          </reference>
        </referencegroup>
        <reference anchor="RFC7252">
          <front>
            <title>The Constrained Application Protocol (CoAP)</title>
            <author fullname="Z. Shelby" initials="Z." surname="Shelby">
              <organization/>
            </author>
            <author fullname="K. Hartke" initials="K." surname="Hartke">
              <organization/>
            </author>
            <author fullname="C. Bormann" initials="C." surname="Bormann">
              <organization/>
            </author>
            <date month="June" year="2014"/>
            <abstract>
              <t>The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained (e.g., low-power, lossy) networks.  The nodes often have 8-bit microcontrollers with small amounts of ROM and RAM, while constrained networks such as IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs) often have high packet error rates and a typical throughput of 10s of kbit/s.  The protocol is designed for machine- to-machine (M2M) applications such as smart energy and building automation.</t>
              <t>CoAP provides a request/response interaction model between application endpoints, supports built-in discovery of services and resources, and includes key concepts of the Web such as URIs and Internet media types.  CoAP is designed to easily interface with HTTP for integration with the Web while meeting specialized requirements such as multicast support, very low overhead, and simplicity for constrained environments.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="7252"/>
          <seriesInfo name="DOI" value="10.17487/RFC7252"/>
        </reference>
        <reference anchor="I-D.bormann-cbor-notable-tags">
          <front>
            <title>Notable CBOR Tags</title>
            <author fullname="Carsten Bormann" initials="C." surname="Bormann">
              <organization>Universität Bremen TZI</organization>
            </author>
            <date day="11" month="July" year="2022"/>
            <abstract>
              <t>   The Concise Binary Object Representation (CBOR, RFC 8949) is a data
   format whose design goals include the possibility of extremely small
   code size, fairly small message size, and extensibility without the
   need for version negotiation.

   In CBOR, one point of extensibility is the definition of CBOR tags.
   RFC 8949's original edition, RFC 7049, defined a basic set of tags as
   well as a registry that can be used to contribute additional tag
   definitions [IANA.cbor-tags].  Since RFC 7049 was published, some 80
   tag definitions have been added to that registry.

   The present document provides a roadmap to a large subset of these
   tag definitions.  Where applicable, it points to a IETF standards or
   standard development document that specifies the tag.  Where no such
   document exists, the intention is to collect specification
   information from the sources of the registrations.  After some more
   development, the present document is intended to be useful as a
   reference document for the IANA registrations of the CBOR tags the
   definitions of which have been collected.

              </t>
            </abstract>
          </front>
          <seriesInfo name="Internet-Draft" value="draft-bormann-cbor-notable-tags-07"/>
        </reference>
      </references>
    </references>
    <section anchor="change-log">
      <name>Change log</name>
      <t>Since -00:</t>
      <ul spacing="normal">
        <li>Update IANA section to reflect registration having been performed.</li>
        <li>Update document lifecycle accordingly, mention possibility of a notable-problem-details document.</li>
        <li>Added security considerations.</li>
      </ul>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA41Y227bOhZ951cQyQBJzkSO45PEjYDBjHPDBOcWpCnm7Qxo
ibaJSqQOScXVBOmXzdv82KxNUo5yaXqKtnEkcnNf1l570VmWMa98JXO+dW50
oZzkN9bMK1nzC+mFqlzOz0zZ8UtrjeU3ximvjN5ipSm0qLGvtGLhM1G7VjqX
FcbKrCmzOfZkkvZkTdqTjQ+ZamzOvW2dn4zHp+MJc17o8t+iMlqGF5IVwudc
6YVh62XOz83tJROtXxmbswzP4c/5iM9q97//Osc4j06cr6xyXgk9eFOYVnvb
5XyG46wSeCRrRJTzol/9j+T2qDA108bWwqt7mWPl7dX56eR0nD5OT49Pc0ZO
DZZ8vLs4PeoXTI4nOWMsyzIu5jhOFJ6xu5VyvJQLpaXjgjull5XkIWRhS96k
RJch0RzGeYv8r5Vfcb+S/BsF4dGLnN3KP+C8f6s+I/aJToOZ4AHt22dk00l7
Ly0vkKnGKO258OGsvkiUYVXK8KyolNR+x3GbDqKiwgq2KF22hSzDslDlUYy9
VmVZSca2+TVyb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