Silent failure when only specify GetBlobOptions's RangeEnd property #79

Closed
jcookems opened this Issue May 19, 2012 · 1 comment

2 participants

@jcookems

It is an error on the server if you specify a range end without a range start, but it is OK to have a start without an end.

However, the service API does hides this fact by silently ignoring range end if there is no range start. Silently changing what the user intended is not good.

The simplest fix would be to allow the bad condition to flow through to the server, and let it complain. This can be accomplished by making this change in PipelineHelpers.java, in

 public static Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) {
-    if (rangeStart != null) {
-        String range = rangeStart.toString() + "-";
-        if (rangeEnd != null) {
-            range += rangeEnd.toString();
-        }
+    if (rangeStart != null || rangeEnd != null) {
+        String range = (rangeStart == null ? "" : rangeStart.toString()) + "-"
+                + (rangeEnd == null ? "" : rangeEnd.toString());
         builder = addOptionalHeader(builder, "Range", "bytes=" + range);
     }
     return builder;
 }

Another choice would be to try to validate in the API, but then it would be more brittle with respect to server changes.

@jcookems

Making P2 because the service itself silently ignores unexpected ranges. Regardless, the API should not preemptively prevent the data from reaching the server.

@gcheng gcheng closed this Jun 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment