grpc-ecosystem/grpc-gateway · error

no value provided

Error message

no value provided

What it means

Returned by populateFieldValueFromPath (via runtime.PopulateFieldFromPath / Parse) when there is a field path but no values to assign to it. Populating a field requires at least one string value extracted from the request.

Source

Thrown at runtime/query.go:110

		// Only singular message fields are allowed
		if fieldDesc.Message() == nil || fieldDesc.Cardinality() == protoreflect.Repeated {
			return fieldPath
		}

		// Get the nested message
		msgValue = msgValue.Get(fieldDesc).Message()
	}

	return newFieldPath
}

func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []string, values []string) error {
	if len(fieldPath) < 1 {
		return errors.New("no field path")
	}
	if len(values) < 1 {
		return errors.New("no value provided")
	}

	var fieldDescriptor protoreflect.FieldDescriptor
	for i, fieldName := range fieldPath {
		fields := msgValue.Descriptor().Fields()

		// Get field by name
		fieldDescriptor = fields.ByName(protoreflect.Name(fieldName))
		if fieldDescriptor == nil {
			fieldDescriptor = fields.ByJSONName(fieldName)
			if fieldDescriptor == nil {
				// We're not returning an error here because this could just be
				// an extra query parameter that isn't part of the request.
				grpclog.Infof("field not found in %q: %q", msgValue.Descriptor().FullName(), strings.Join(fieldPath, "."))
				return nil
			}
		}

View on GitHub (pinned to a58a4436a3)

Solutions

  1. Ensure at least one value string is passed for the field path (default it if the parameter is absent)
  2. Check the URL/query actually contains the parameter the path refers to before calling PopulateFieldFromPath
  3. Guard the call: skip population when len(values) == 0

Example fix

// before
err := populate(msgValue, []string{"id"}, nil)
// after
if len(vals) == 0 { vals = []string{defaultValue} }
err := populate(msgValue, []string{"id"}, vals)
Defensive patterns

Strategy: validation

Validate before calling

if len(fieldPath) > 0 && len(values) == 0 {
    values = []string{defaultFor(fieldPath)} // or skip population
}

Type guard

func hasValues(values []string) bool {
    return len(values) > 0
}

Try / catch

if err := runtime.PopulateFieldFromPath(msg, urlPath, fieldPath); err != nil {
    return fmt.Errorf("populate %q: %w", fieldPath, err)
}

Prevention

When it happens

Trigger: Calling runtime.PopulateFieldFromPath with a valid fieldPath but empty values slice; query parsing that yields zero values for a named parameter (e.g. a query key present with no value routed through Parse).

Common situations: Custom request mapping where a template variable matched nothing; passing strings.Split result that returned an empty slice; wiring a query parameter key that is never populated from the URL.

Related errors


AI-assisted analysis of grpc-ecosystem/grpc-gateway@a58a4436a3 (2026-09-02). Data as JSON: /api/errors/e22245de73f50e23. Report an issue: GitHub.