fix(data-connect): Include connector in DataConnect cache key by itok01 · Pull Request #3055 · firebase/firebase-admin-node
The `DataConnectService.getDataConnect()` method was caching
DataConnect instances using only `location` and `serviceId` as the
cache key, ignoring the `connector` field.
This caused a bug where calling `getDataConnect()` with different
connector configs but the same location and serviceId would return
the same (first) cached instance instead of creating separate
instances for each connector.
**Problem:**
```typescript
const dc1 = getDataConnect({ location: 'us-west2', serviceId: 'svc', connector: 'public' });
const dc2 = getDataConnect({ location: 'us-west2', serviceId: 'svc', connector: 'user' });
// dc1 === dc2 was true (BUG!)
// dc2.connectorConfig.connector was 'public' instead of 'user'
```
**Solution:**
Include `connector` in the cache key:
```typescript
const id = `${location}-${serviceId}-${connector ?? ''}`;
```
**Impact:**
This bug affects any application using multiple Data Connect connectors
with the same location and serviceId. Operations intended for one
connector would be incorrectly routed to another, causing "operation
not found" errors.
**Tests:**
Added 5 new tests to verify cache key behavior with different
connector configurations.