52North / SOS

52°North Sensor Observation Service
https://52north.org/software/software-projects/sos/
GNU General Public License v2.0
109 stars 82 forks source link

InsertResult with values in wrong format returns wrong exception text #755

Closed EHJ-52n closed 4 years ago

EHJ-52n commented 4 years ago

The SOS returns the following error response, when sending an InsertResult request with valid <template> but invalid <resultValues>, :

Request

<?xml version="1.0" encoding="UTF-8"?>
  <sos:InsertResult xmlns:sos="http://www.opengis.net/sos/2.0" service="SOS" version="2.0.0">
  <sos:template>my-valid-example-template-id</sos:template>
  <sos:resultValues>24@some-invalid//2020-01-01@values//20202-01-02</sos:resultValues>
</sos:InsertResult>

Response

<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsAll.xsd">
  <ows:Exception exceptionCode="InvalidParameterValue" locator="identifier">
    <ows:ExceptionText>The requested resultTemplate identifier (my-valid-example-template-id) is already registered at this service</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

Here, the locator should be template, or not?

I expected something like this:

<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsAll.xsd">
  <ows:Exception exceptionCode="InvalidParameterValue" locator="resultValues">
    <ows:ExceptionText>The received resultValues format does not comply to the resultStructure of the resultTemplate 'my-valid-example-template-id'!</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

The according exception with the correct message is already there, as you can see from the server's stack trace:

09:26:27.039 [http-nio-8080-exec-5] WARN  PoxBinding - Unexpected error
org.n52.shetland.ogc.ows.exception.InvalidParameterValueException: The resultValues format does not comply to the resultStructure of the resultTemplate!
    at org.n52.sos.ds.hibernate.InsertResultHandler.getSingleObservationsFromObservation(InsertResultHandler.java:327)
    at org.n52.sos.ds.hibernate.InsertResultHandler.insertResult(InsertResultHandler.java:164)
    at org.n52.sos.request.operator.SosInsertResultOperatorV20.receive(SosInsertResultOperatorV20.java:75)
    at org.n52.sos.request.operator.SosInsertResultOperatorV20.receive(SosInsertResultOperatorV20.java:51)
    at org.n52.sos.request.operator.AbstractRequestOperator.receiveRequest(AbstractRequestOperator.java:380)
    at org.n52.sos.request.operator.AbstractTransactionalRequestOperator.receiveRequest(AbstractTransactionalRequestOperator.java:86)
    at org.n52.iceland.service.operator.GenericServiceOperator.receiveRequest(GenericServiceOperator.java:100)
    at org.n52.iceland.binding.pox.PoxBinding.doPostOperation(PoxBinding.java:86)
CarstenHollmann commented 4 years ago

I can not reproduce this issue. During the testing the returned exception message was the expected The resultValues format does not comply to the resultStructure of the resultTemplate! .