<?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-00" 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-00"/>
    <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="04"/>
    <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/problem-detail-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).</t>
        <t>It is the author's opinion that an Interned Draft can provide sufficient specification,
and is more suitable than an informal note published at some arbitrary website
due to its archival through the draft submission process.</t>
        <t>It is not expected that this draft will proceed all the way to an RFC;
instead, once sufficiently mature, it will be used as a reference in a request to IANA,
and updated with the assigned number.</t>
        <t>This document will eventually expire as an Internet Draft,
but nonetheless be usable as the permanent reference for the assigned problem detail.</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="iana-considerations">
      <name>IANA considerations</name>
      <t>A new entry is requested for 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>
  </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" target="https://www.rfc-editor.org/info/std94">
          <reference anchor="RFC8949" target="https://www.rfc-editor.org/info/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>
      </references>
    </references>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA41XXW/juhF9568YJAWSoJbj+MZxoqJA84kGbe8Nsln07Ra0
RNvESqQuScVxA+8v61v/WM+QsuN8bHoXMFaRyOGZmTNnhlmWiaBDpXLaubSm
0F7RnbOTStV0pYLUlc/pwpZLunbOOrqzXgdtzY4obWFkjX2lk9OQydq3yvus
sE5lTZlNsCdTvCdruj3ZYCB043IKrvVhOBicDYbCB2nKf8nKGhU/KFHIkJM2
UysWs5wu7f21kG2YW5eLDO+B57JP57X/73+8F0QJxOXcaR+0NFtfCtua4JY5
neM4pyVeqRoe5VSsV/+lg90vbC2MdbUM+lHlWHl/c3k2PBt0j+Oz0VkuGNTW
ki8PV2fH6wXD0TAXQmRZRnKC42QRhHiYa0+lmmqjPEny2swqRdFl6UpqukCX
MdAE49Qi/gsd5h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