# Issue #275: Fix silent connection initiation failures

## Objective

Fix silent connection initiation failures where HTTP errors are caught but success is returned to the user, leaving zombie connections in PENDING state forever.

## Location

`apps/api/src/federation/connection.service.ts:72-80`

## Problem

Current code:

```typescript
try {
  await firstValueFrom(
    this.httpService.post(`${remoteUrl}/api/v1/federation/incoming/connect`, signedRequest)
  );
  this.logger.log(`Connection request sent to ${remoteUrl}`);
} catch (error) {
  this.logger.error(`Failed to send connection request to ${remoteUrl}`, error);
  // Connection is still created in PENDING state, can be retried
}

return this.mapToConnectionDetails(connection);
```

Issues:

- Catches HTTP failures but returns success
- Connection stays in PENDING state forever
- Creates zombie connections
- User sees success message but connection actually failed

## Solution

1. Delete the failed connection from database
2. Throw exception with clear error message
3. User gets immediate feedback that connection failed

## Implementation

```typescript
try {
  await firstValueFrom(
    this.httpService.post(`${remoteUrl}/api/v1/federation/incoming/connect`, signedRequest)
  );
  this.logger.log(`Connection request sent to ${remoteUrl}`);
} catch (error) {
  this.logger.error(`Failed to send connection request to ${remoteUrl}`, error);

  // Delete the failed connection to prevent zombie connections
  await this.prisma.federationConnection.delete({
    where: { id: connection.id },
  });

  throw new BadRequestException(
    `Failed to initiate connection to ${remoteUrl}: ${error instanceof Error ? error.message : "Unknown error"}`
  );
}
```

## Testing

Test scenarios:

1. Remote instance is unreachable - should throw exception and delete connection
2. Remote instance returns error - should throw exception and delete connection
3. Remote instance times out - should throw exception and delete connection
4. Remote instance returns success - should create connection in PENDING state

## Progress

- [ ] Create scratchpad
- [ ] Implement fix in connection.service.ts
- [ ] Add/update tests
- [ ] Run quality gates
- [ ] Commit changes
- [ ] Create PR
- [ ] Merge to develop
- [ ] Close issue #275
