Skip to content

Adds proxy support using the Alpha client - #1178

Merged
nickjupiter1 merged 7 commits into
mainfrom
nick/proxy-support-alpha
Sep 10, 2025
Merged

Adds proxy support using the Alpha client#1178
nickjupiter1 merged 7 commits into
mainfrom
nick/proxy-support-alpha

Conversation

@nickjupiter1

Copy link
Copy Markdown
Contributor

@nickjupiter1
nickjupiter1 requested a review from a team as a code owner September 10, 2025 15:23

This comment was marked as outdated.

Copilot AI 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.

Pull Request Overview

This pull request adds proxy support to the JupiterOne integration SDK by integrating proxy configuration with the Alpha HTTP client. The changes enable integration developers to route API requests through HTTP/HTTPS proxies for network environments that require them.

Key changes:

  • Extended the createApiClient function to accept an optional proxyUrl parameter and automatically detect proxy settings from environment variables
  • Added proxy URL parsing functionality with authentication support and error handling
  • Implemented comprehensive test coverage for various proxy configuration scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/integration-sdk-runtime/src/api/index.ts Core implementation adding proxy support with URL parsing and environment variable detection
packages/integration-sdk-runtime/src/api/tests/index.test.ts Comprehensive test suite covering proxy configuration scenarios and edge cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const url = new URL(proxyUrl);
const proxy: AxiosProxyConfig = {
host: url.hostname,
port: parseInt(url.port) || (url.protocol === 'https:' ? 443 : 80),

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

The parseInt function should specify a radix parameter to avoid potential parsing issues. Use parseInt(url.port, 10) to ensure decimal parsing.

Suggested change
port: parseInt(url.port) || (url.protocol === 'https:' ? 443 : 80),
port: parseInt(url.port, 10) || (url.protocol === 'https:' ? 443 : 80),

Copilot uses AI. Check for mistakes.
const proxy: AxiosProxyConfig = {
host: url.hostname,
port: parseInt(url.port) || (url.protocol === 'https:' ? 443 : 80),
protocol: url.protocol.replace(':', ''),

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The protocol manipulation could be more explicit. Consider using url.protocol.slice(0, -1) or add a comment explaining that this removes the trailing colon from protocols like 'https:' to get 'https'.

Suggested change
protocol: url.protocol.replace(':', ''),
// Remove the trailing colon from protocol (e.g., 'https:' -> 'https')
protocol: url.protocol.slice(0, -1),

Copilot uses AI. Check for mistakes.
return proxy;
} catch (error) {
const parsedError = error instanceof TypeError ? error : new TypeError(String(error));
console.warn('Failed to parse proxy URL:', proxyUrl, parsedError);

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 code only executes if proxyUrlString is populated, so if there is a proxy config, and we cannot parse it, its not safe to continue without the proxy

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.

Agreed! I modified it to not catch the error.

@nickjupiter1
nickjupiter1 merged commit bdb87b2 into main Sep 10, 2025
8 checks passed
@nickjupiter1
nickjupiter1 deleted the nick/proxy-support-alpha branch September 10, 2025 16:40
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