googleapis/mcp-toolbox · error

range %q is missing '-'

Error message

range %q is missing '-'

What it means

Range-parser guard in parseRange: the spec after the 'bytes=' prefix contains no '-' separator, so it is neither a start-end, open-ended, nor suffix range.

Source

Thrown at internal/tools/cloudstorage/cloudstoragereadobject/cloudstoragereadobject.go:171

//
//	""           → (0, -1)       // full object
//	"bytes=0-9"  → (0, 10)       // first 10 bytes
//	"bytes=10-"  → (10, -1)      // from byte 10 to end
//	"bytes=-N"   → (-N, -1)      // last N bytes
func parseRange(rangeSpec string) (offset int64, length int64, err error) {
	if rangeSpec == "" {
		return 0, -1, nil
	}

	spec := strings.TrimSpace(rangeSpec)
	if !strings.HasPrefix(spec, "bytes=") {
		return 0, 0, fmt.Errorf("range %q must start with 'bytes='", rangeSpec)
	}
	spec = strings.TrimPrefix(spec, "bytes=")

	dash := strings.IndexByte(spec, '-')
	if dash < 0 {
		return 0, 0, fmt.Errorf("range %q is missing '-'", rangeSpec)
	}

	startStr := spec[:dash]
	endStr := spec[dash+1:]

	switch {
	case startStr == "" && endStr == "":
		return 0, 0, fmt.Errorf("range %q requires at least one bound", rangeSpec)

	case startStr == "":
		n, parseErr := strconv.ParseInt(endStr, 10, 64)
		if parseErr != nil || n <= 0 {
			return 0, 0, fmt.Errorf("range %q has a bad suffix length", rangeSpec)
		}
		return -n, -1, nil

	case endStr == "":
		start, parseErr := strconv.ParseInt(startStr, 10, 64)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Use the HTTP range syntax 'bytes=<start>-<end>', 'bytes=<start>-' or 'bytes=-<n>'
  2. Omit the range parameter entirely to read the whole object
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/tools/cloudstorage/cloudstoragereadobject/cloudstoragereadobject.go:171 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/d7db665745c79335. Report an issue: GitHub.