googleapis/mcp-toolbox · error

no document found

Error message

no document found

What it means

validatePath (internal to validator.go, used by ValidateCollectionPath and ValidateDocumentPath) rejects an empty path string before any other check. pathTypeName is "collection" or "document" depending on the requested path type, so the message reads e.g. "collection path cannot be empty".

Source

Thrown at internal/sources/mongodb/mongodb.go:280

		return nil, fmt.Errorf("error updating collection: %w", err)
	}
	return res.ModifiedCount, nil
}

func (s *Source) DeleteMany(ctx context.Context, filterString, database, collection string) (any, error) {
	var filter = bson.D{}
	err := bson.UnmarshalExtJSON([]byte(filterString), false, &filter)
	if err != nil {
		return nil, err
	}

	res, err := s.MongoClient().Database(database).Collection(collection).DeleteMany(ctx, filter, options.DeleteMany())
	if err != nil {
		return nil, err
	}

	if res.DeletedCount == 0 {
		return nil, errors.New("no document found")
	}
	return res.DeletedCount, nil
}

func (s *Source) DeleteOne(ctx context.Context, filterString, database, collection string) (any, error) {
	var filter = bson.D{}
	err := bson.UnmarshalExtJSON([]byte(filterString), false, &filter)
	if err != nil {
		return nil, err
	}

	res, err := s.MongoClient().Database(database).Collection(collection).DeleteOne(ctx, filter, options.DeleteOne())
	if err != nil {
		return nil, err
	}
	return res.DeletedCount, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Supply a non-empty collection or document path such as "users" or "users/userId".
  2. Check the caller/config that produced the empty string and require the parameter before invoking the validator.
  3. For document paths, use the odd number of segments form (e.g. "users/userId").

Example fix

// before
err := ValidateCollectionPath("")
// after
if collection == "" { return errors.New("collection is required") }
err := ValidateCollectionPath(collection)
Defensive patterns

Strategy: validation

Validate before calling

func requireNonEmptyPath(p string, kind string) error { if strings.TrimSpace(p) == "" { return fmt.Errorf("%s path is required", kind) }; return nil }

Try / catch

if err := ValidateCollectionPath(path); err != nil {
    if strings.Contains(err.Error(), "path cannot be empty") { /* prompt user / read missing config and retry */ }
}

Prevention

When it happens

Trigger: Calling ValidateCollectionPath("") or ValidateDocumentPath(""); a tool parameter bound to an empty query/POST field; an env var or config key for a collection/document ID left unset.

Common situations: Missing query parameter in an HTTP request; user left the collection/document ID blank; config file with an empty value for the path field.

Related errors


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