approved join on single word crashes the text

Issue #46 resolved
Craig Berry created an issue

If there is an approved join that "joins" a single word with itself, the text in which it occurs cannot be displayed and throws the following error:

500Merging error. err:XPTY0004: It is a type error if, during the static analysis phase, an expression is found to have a static type that is not appropriate for the context in which the expression occurs, or during the dynamic evaluation phase, the dynamic type of a value does not match a required type as specified by the matching rules in 2.5.4 SequenceType Matching. checking function parameter 1 in call map:entry(untyped-value-check[xs:anyAtomicType, $lca], $annotation): XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: map:entry($key as xs:anyAtomicType, $value as item()*) map. Expected cardinality: exactly one, got 0.

An example of an annotation that causes this:

<annotation-item generator="earlyPrint" id="Ad885068d-3df1-4bf9-ad9f-7c14b220aec7" status="accepted" visibility="public" reason="" creator="elisabeth.chaghafi@uni-tuebingen.de" created="2017-10-10T16:19:57.244Z" modified="2017-10-10T16:19:57.244Z" generated="2017-10-10T16:19:57.244Z" ticket="s-1507652397243">
  <annotation-body subtype="join" format="text/xml" type="TEI" original-value="shore">
    <w>shore</w>
  </annotation-body>
  <annotation-target source="A12024" version="">
    <target-selector type="RangeSelector">
      <start-selector type="IdSelector" value="tmp-1507652332693"/>
      <end-selector type="IdSelector" value="A12024-021-b-0440"/>
    </target-selector>
  </annotation-target>
</annotation-item>

Note that the start-selector is pointing to a temporary ID rather than the xml:id of a real word; that may well be the root of the issue.

The annotation client should not allow such an annotation to be created, and the annotation service should not fall down so hard when it encounters one.

Comments (3)

  1. Craig Berry reporter

    This should be substantially mitigated by the following change to the annotation service, but the client should still do its own validation:

    commit 61afb0144393af9bad262dc672fd2e1c85a5bb58
    Author: Craig A. Berry <craigberry@mac.com>
    Date:   Sun Nov 25 09:36:12 2018 -0600
    
        Validate annotation targets before storing.
    
        The client occasionally submits an annotation with auto-generated
        word IDs rather than real ones.  The client should be fixed to do
        its own validation, but in the meantime, validate the word IDs in
        the server and reject annotations that do not validate.  This will
        hopefully avoid various kinds of crashes that occur when merging
        non-existent words into the text.
    
  2. Craig Berry reporter

    We are no longer using the merge feature of the annotation service, so we will not see merge errors. While the client could still do more validation, that was not the critical problem noted here.

  3. Craig Berry reporter

    We are no longer using the merge feature of the annotation service, so we will not see merge errors. While the client could still do more validation, that was not the critical problem noted here.

  4. Log in to comment