getodk / briefcase

ODK Briefcase is a Java application for fetching and pushing forms and their contents. It helps make billions of data points from ODK portable. Contribute and make the world a better place! ✨💼✨
https://docs.getodk.org/briefcase-intro
Other
60 stars 156 forks source link

On pushToAggregate request header "X-OpenRosa-Version -> 1.0" is set twice and give a java Error under aggregate cause it parsing it as double "1.0, 1,0" #854

Closed yougis closed 4 years ago

yougis commented 4 years ago

Software versions

Briefcase v1.7.2, Java v1.8, operating system, Aggregate v2.0.5

Problem description

Impossible to push aggregate forms

Steps to reproduce the problem

push form to aggregate 1.7.x or 2.0.5

Expected behavior

form should be pushed without error

Other information

.... Bad Gateway Sending submission 23 of 40 Error sending submission 23 of 40: Erreur Interne de Servlet

When debuging

the method uncheckedExecute in CommonsHttp.java is adding the header ("X-OpenRosa-Version", "1.0") in headerGroup but this headerGroup is already sets by getPushSubmissionRequest in AgrgegateServer.java This cause an error in aggregate side when it gets the Header's value. The value return by getHeader is now "1.0, 1.0" and not "1.0" `public String getHeader(String name);

/**
 * Returns all the values of the specified request header
 * as an <code>Enumeration</code> of <code>String</code> objects.`

This is understandable because header has 2 entries of "X-OpenRosa-Version" and getHeader concatenating them.

I hope, I am clear.

yougis commented 4 years ago

resolve by a workaround like this :

if(!request.headers.containsKey("X-OpenRosa-Version")){
       commonsRequest.addHeader("X-OpenRosa-Version", "1.0");
}

Not sure it's very clean ...