googleapis/mcp-toolbox · error

resources cannot be empty

Error message

resources cannot be empty

What it means

dataplex-lookup-context accepts a `resources` array parameter naming Dataplex entries to resolve. Invoke rejects the call when the converted array is empty, because the underlying Dataplex LookupContext API needs at least one resource. It surfaces as an AgentError to the LLM/client.

Source

Thrown at internal/tools/dataplex/dataplexlookupcontext/dataplexlookupcontext.go:122

		return fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
	}
	return nil
}

func (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {
	source, ok := s.(compatibleSource)
	if !ok {
		return nil, util.NewClientServerError("source used is not compatible with the tool", http.StatusInternalServerError, nil)
	}
	paramsMap := params.AsMap()
	resourcesSlice, err := parameters.ConvertAnySliceToTyped(paramsMap["resources"].([]any), "string")
	if err != nil {
		return nil, util.NewAgentError(fmt.Sprintf("can't convert resources to array of strings: %s", err), err)
	}
	resources := resourcesSlice.([]string)

	if len(resources) == 0 {
		err := fmt.Errorf("resources cannot be empty")
		return nil, util.NewAgentError(err.Error(), err)
	}
	var name string
	var firstLocation string
	for i, resource := range resources {
		parts := strings.Split(resource, "/")
		if len(parts) < 4 || parts[0] != "projects" || parts[2] != "locations" {
			err := fmt.Errorf("invalid resource format at index %d, must be in the format of projects/{project_id_or_number}/locations/{location}/entryGroups/{group}/entries/{entry}", i)
			return nil, util.NewAgentError(err.Error(), err)
		}

		location := parts[3]
		if i == 0 {
			firstLocation = location
			project := source.ProjectID()
			name = fmt.Sprintf("projects/%s/locations/%s", project, location)
		} else if location != firstLocation {
			err := fmt.Errorf("all resources must belong to the same location. Please make separate calls for each distinct location")

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Pass at least one fully-qualified entry resource in the resources array
  2. Validate the array is non-empty before invoking the tool
  3. If the intent is a broad search, use dataplex-search-entries instead

Example fix

// before
{"resources": []}
// after
{"resources": ["projects/my-proj/locations/us-central1/entryGroups/my-group/entries/my-entry"]}
Defensive patterns

Strategy: validation

Validate before calling

if len(resources) == 0 {
	return fmt.Errorf("resources must contain at least one fully-qualified entry name")
}

Try / catch

resp, terr := tool.Invoke(ctx, src, params, token)
if terr != nil {
	// AgentError: empty resources — repopulate the list before retrying
	return handleAgentError(terr)
}

Prevention

When it happens

Trigger: Invoking dataplex-lookup-context with resources: [] (empty array) or a parameter that converts to a zero-length string slice.

Common situations: LLM agent omits or sends an empty resources list; client template renders no values into the array; upstream filtering removed all items before the call.

Related errors


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