chore(runtime): remove @lifeomic/alpha in favor of plain axios - #1209
Open
Gonzalo-Avalos-Ribas wants to merge 2 commits into
Open
chore(runtime): remove @lifeomic/alpha in favor of plain axios#1209Gonzalo-Avalos-Ribas wants to merge 2 commits into
Gonzalo-Avalos-Ribas wants to merge 2 commits into
Conversation
The SDK only ever pointed its API client at https api.us.jupiterone.io or api.dev.jupiterone.io. Alpha's reason to exist, SigV4-signed lambda:// invocation, was never used here, but it anchored axios 0.27.2 plus 94 transitive production packages (28 @aws-sdk, 45 @smithy). createApiClient now returns a plain axios instance. Alpha's retry behavior is reimplemented in api/retry.ts with identical semantics: the same defaults (3 retries, factor 2, 10s cap), the same exponential-backoff-with-jitter formula, and the same retry condition (5xx or no response, never ECONNABORTED). The retry interceptor is registered before the header-redaction interceptor. Redaction overwrites error.config.headers, and retry replays that config, so the reverse order would strip Authorization from every retried request. Alpha got this ordering for free by registering retry inside its own constructor. axios was previously a phantom dependency: imported in 10 files but declared nowhere, resolved only via alpha's hoisted copy. It is now a real dependency of integration-sdk-runtime and a devDependency of cli. Adds api/__tests__/retry.test.ts, covering retry counts, backoff opt-out, connection-level failures, gzip upload compression and token redaction against a real local HTTP server. Retry and compression previously had no direct coverage. BREAKING CHANGE: ApiClient is now AxiosInstance rather than Alpha. The createApiClient alphaOptions parameter is deprecated in favor of axiosOptions; both are still honored.
…tries A retry replays the same config object through the full interceptor chain, so compressRequest saw config.data already holding the gzip buffer from the previous attempt and compressed it again. The retried request advertised a single Content-Encoding: gzip for a doubly-compressed body, which the server cannot decode -- silent corruption on exactly the path retry exists to serve. Mark the config once compressed and skip on replay. Also: - clone retry options before applying defaults, so a caller reusing one retryOptions object across clients does not leak state - require isAxiosError on the retry condition, so a programming error thrown from a downstream interceptor surfaces immediately instead of being replayed - document that axiosOptions takes precedence over the deprecated alphaOptions Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
@lifeomic/alphafrom the SDK.createApiClientnow returns a plainaxiosinstance, with alpha's retry behavior reimplemented inpackages/integration-sdk-runtime/src/api/retry.ts.Why
Alpha is a Lambda-aware HTTP client whose purpose is resolving
lambda://URLs via SigV4. The SDK never uses that.createApiClientis only ever pointed atJUPITERONE_PROD_API_BASE_URLorJUPITERONE_DEV_API_BASE_URL; there is nolambda://URL anywhere in this repo. Everything the SDK actually used from alpha — an axios-compatible client, theretryoption, and interceptors — is either plain axios or ~130 lines of retry logic.What alpha did bring was a large, stale dependency subtree: 28
@aws-sdkand 45@smithypackages, plus a pin toaxios@0.27.2.Bumping alpha to 7.1.0 was tried first and rejected. It fails to compile — 8x
TS2416inside alpha's own shipped.d.ts, because alpha 7.1.0 predates axios's two-genericAxiosRequestConfig<D, P>:Pinning axios back to 1.12.2 makes it compile but reintroduces 28 advisories. Alpha 7.1.0 also drags in
aws-xray-sdk-core->cls-hooked, which enablesasync_hooksprocess-wide and breaks 3FileSystemGraphObjectStoretests. Downgrading to 5.1.3 does not work either: it declares axios as apeerDependency(0.24.x || ... || 0.27.x), which npm 7+ auto-installs, so the old copy survives and cannot accept axios 1.x.What changed
packages/integration-sdk-runtime/package.json— drop@lifeomic/alpha, addaxios ^1.20.0src/api/index.ts—axios.create()instead ofnew Alpha();ApiClientis nowAxiosInstancesrc/api/retry.ts— new, alpha's retry reimplementedsrc/synchronization/index.ts,packages/cli/src/import/importAssetsFromCsv.ts— type-only updatespackages/cli/package.json— axios devDependency for typecheckRetry semantics are unchanged
The replacement was written against alpha 5.2.0's original TypeScript (recovered from its published sourcemap), not approximated. Same defaults (3 retries -> 4 attempts, factor 2, 10s cap), same
min(factor^n * random()*1000 * (1 - random()%0.3), maxTimeout)backoff, same retry condition.axios-retrywas deliberately not used because its backoff differs.Two bugs fixed along the way
Interceptor ordering. Retry must register before the redaction interceptor. Redaction overwrites
error.config.headers = '[REDACTED]'and retry replays that config, so the reverse order makes retried requests silently drop theirAuthorizationheader. Alpha got this ordering for free inside its constructor. Covered by a test that fails when the order is swapped.Double compression on retry (
ef84156). A retry replays the same config through the full interceptor chain, socompressRequestsawconfig.dataalready holding the gzip buffer from the previous attempt and compressed it again — sending a doubly-gzipped body under a singleContent-Encoding: gzip. Verified against a live server:This predates the branch (alpha replayed config the same way) but is fixed here. It fires on exactly the case retry exists to serve — a 5xx from the persister under load — and fails silently client-side.
A latent phantom dependency
axioswas imported in 10 files but declared in no manifest, resolving only through alpha's hoisted copy. Removing alpha would have broken the build without declaring it.Compatibility
ApiClientis nowAxiosInstance. SinceAlphaextendedAxios, callers using.get/.post/.requestare unaffected.alphaOptionsis retained and still honored, marked@deprecated, withaxiosOptionsadded alongside.AlphaOptionswas never re-exported, so it was not public API.compressRequestis exported and its signature changes fromAlphaInterceptortoInternalAxiosRequestConfig.Checked against
JupiterOne/integrations: zeroalphaOptionscallers, and the single real consumer of the SDK'screateApiClient(deployments/snyk/src/ecs/microIngestion/microSync.ts:266) passes onlyaccountandapiBaseUrland calls.post(). No alpha-specific keys (lambda,context,signAwsV4) are used anywhere.This warrants a major bump (17.6.1 -> 18.0.0) since
ApiClientandcompressRequestare exported.Impact
Prunes 94 production-reachable packages (28
@aws-sdk, 45@smithy) and clears 33 of this repo's open Dependabot alerts: 23 axios, 6 fast-xml-parser, 2 form-data, 1 follow-redirects, 1@smithy/config-resolver.The 22 remaining axios alerts are all
nx's bundledaxios@1.6.8— build tooling, devDependency only. The newaxios@1.20.0carries zero alerts.Testing
npm run build— clean, with noskipLibChecknpx jest— 73 suites, 750 passed, 1 skipped, 0 failedprettier --checkcleancontent-encoding: gzipreceived,gunzipSyncround-trips)Not verified: no downstream integration was executed against this build — only SDK packages typecheck against the new
ApiClient. No authenticated calls to the real J1 API were made, so retry and compression are proven against a local server, not production.Sequencing
This rewrites 7,269 lines of
package-lock.jsonand will conflict hard with any other lockfile PR. Whichever lands second should discard its lockfile diff and re-runnpm installrather than resolving the conflict by hand.