github/github-mcp-server · error

value must be greater than zero (got %d)

Error message

value must be greater than zero (got %d)

What it means

Raised by validatePositiveInt64 (pkg/github/projects_batch.go:490) when a value converts to int64 cleanly but is zero or negative. It is the innermost cause for item_id and updated_field.id, surfacing wrapped as e.g. 'item_id: value must be greater than zero (got 0)'. The affected item (or the whole request, for updated_field.id) fails validation before any API call.

Source

Thrown at pkg/github/projects_batch.go:490

		return 0, fmt.Errorf("missing %s", key)
	}
	n, err := validatePositiveInt64(v)
	if err != nil {
		return 0, fmt.Errorf("%s must be a positive integer: %w", key, err)
	}
	if n > math.MaxInt32 {
		return 0, fmt.Errorf("%s exceeds the GraphQL Int maximum of %d", key, int64(math.MaxInt32))
	}
	return int(n), nil
}

func validatePositiveInt64(value any) (int64, error) {
	n, err := validateAndConvertToInt64(value)
	if err != nil {
		return 0, err
	}
	if n <= 0 {
		return 0, fmt.Errorf("value must be greater than zero (got %d)", n)
	}
	return n, nil
}

type batchFieldSpec struct {
	id    int64
	name  string
	value any
}

func parseBatchFieldSpec(raw any) (batchFieldSpec, error) {
	var spec batchFieldSpec
	input, ok := raw.(map[string]any)
	if !ok || input == nil {
		return spec, fmt.Errorf("updated_field must be an object")
	}

	value, hasValue := input["value"]

View on GitHub (pinned to 0ea1f775a7)

Solutions

  1. Find where the 0/negative value originates — usually a failed upstream lookup — and fix that
  2. Skip items whose ID could not be resolved instead of sending 0
  3. Assert id > 0 before adding the item to the batch or setting updated_field.id
  4. Note GitHub item database IDs are always large positive integers; a small number like 0 or 1 is a mapping bug

Example fix

// before
{"items": [{"item_id": 0}]}
// after
// resolve the real database ID first, then:
{"items": [{"item_id": 9012345678}]}
Defensive patterns

Strategy: validation

Validate before calling

if f, ok := entry["item_id"].(float64); ok && int64(f) <= 0 {
	return fmt.Errorf("item_id must be > 0 (got %d)", int64(f))
}
// same check for updated_field["id"]

Type guard

func isPositiveJSONInt(v any) bool { f, ok := v.(float64); return ok && int64(f) > 0 }

Prevention

When it happens

Trigger: {"item_id": 0} or {"item_id": -3} — integral numbers that pass conversion but fail the > 0 check; likewise updated_field:{"id":0, ...}. Zero typically leaks from an uninitialized variable or a failed lookup that defaulted to 0.

Common situations: Go/JSON zero values from unfilled struct fields; a lookup that failed silently and returned 0 before the batch was built; sentinel -1 from 'not found' conventions forwarded verbatim.

Related errors


AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15). Data as JSON: /api/errors/10fe9286a7aa1f9e. Report an issue: GitHub.