Skip to content

feat: implement client to abstract bridge calls#226

Open
pranishnepal wants to merge 1 commit into
masterfrom
WCN-742
Open

feat: implement client to abstract bridge calls#226
pranishnepal wants to merge 1 commit into
masterfrom
WCN-742

Conversation

@pranishnepal

Copy link
Copy Markdown
Contributor

This PR implements a client for the bridge service, which will be used by the master Bitgo Express server to forward certain requests to the bridge service.

A base HTTP Client has been implemented and the the existing keyProvider has been refactored to extend it as well.

Tests have been added for the new client and existing tests for the keyProvider have been updated whereby necessary(error handling changes).

Ticket: WCN-743

@linear-code

linear-code Bot commented Jun 9, 2026

Copy link
Copy Markdown

WCN-742

@pranishnepal pranishnepal marked this pull request as ready for review June 9, 2026 18:38
@pranishnepal pranishnepal requested review from a team as code owners June 9, 2026 18:38
UpdateJobParams,
} from './bridgeClient.types';

export class BridgeClient extends BaseHttpClient {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should have a generic interface, with a specific implementation.

e.x. BridgeClient would be the interface, and the implementation would be OsoBridgeClient

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that'll make it easy to swap in a different bridge; added an interface and a switched the previous class to a concrete implementation for OSO!

@pranishnepal pranishnepal force-pushed the WCN-742 branch 2 times, most recently from c77331f to d7d4d1f Compare June 9, 2026 20:35
@zahin-mohammad

Copy link
Copy Markdown
Contributor

@claude

Comment thread src/shared/httpClient.ts Outdated
throw new ConflictError(error.response?.body.message);
default:
throw new Error(
`${ctx}${error.status ? ` [${error.status}]` : ''}${

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default case now includes the internal URL in the error message, which surfaces in details on 500 responses to clients. the old keyProviderClient threw just the message for 500s.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, i figured it'd be fine since it's error messaging, but i reverted to original way + the className to differentiate. Added a test case to validate also

async submit(params: SubmitParams): Promise<SubmitResponse> {
const path = params.path.startsWith('/') ? params.path : `/${params.path}`;
const headers: Record<string, string> = {
'X-OSO-Source': params.sources.join(','),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to handle "user,backup" without spaces.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already being handled, see test case -- /submit receives in it's body param [user, backup], and we use .join() to send as user,backup

const response = await this.call('get', `${this.url}/jobs`, { query });

const jobs: BridgeJobResponse[] = [];
for (const job of response.body?.jobs ?? []) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.body?.jobs ?? [] silently returns empty on a malformed envelope.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, updated to throw when jobs isn't available. Added a test case also. Thank you!

This PR implements a client for the bridge service, which will be used
by the master Bitgo Express server to forward certain requests to the
bridge service.

A base HTTP Client has been implemented and the the existing keyProvider
has been refactored to extend it as well.

Tests have been added for the new client and existing tests for the
keyProvider have been updated whereby necessary(error handling changes).

Ticket: WCN-743

@zahin-mohammad zahin-mohammad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will defer to @pranavjain97 's review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants