Repository navigation
feat(api): add ENABLE_INGESTION_API_KEY to honor INGESTION_API_KEY on the app image - #3633
Conversation
🦋 Changeset detectedLatest commit: 1399601 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@andrewdunndev is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
PR Review
1 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 0 P3 1 posted as inline comment(s) on the changed lines. Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This is a small, well-contained change that adds an opt-in No P2 findings. The residual considerations below are informational only — each is pre-existing to the all-in-one/dev path and merely becomes reachable on the app image through an explicit, default-off opt-in, so none is a regression introduced by this diff:
Reviewers (4): correctness, security, testing, maintainability. Testing gaps: None substantive — the new opt-in branch (on/off/empty-key) is covered; the one "gap" raised (asserting the preset key is only emitted when |
| config.IS_ALL_IN_ONE_IMAGE || | ||
| config.IS_LOCAL_APP_MODE || | ||
| config.IS_DEV || | ||
| config.ENABLE_INGESTION_API_KEY |
There was a problem hiding this comment.
🟡 P2 — With ENABLE_INGESTION_API_KEY on and no team yet, the app image opens an OTLP receiver with no auth
buildOtelCollectorConfig gets teams from getAllTeams (line 604). When that list is empty (fresh install, or a rebuilt DB before anyone registers, which is the case this PR targets), apiKeys ends up as [INGESTION_API_KEY]. That passes the apiKeys.length > 0 check at line 348, so otlp/hyperdx gets wired into every pipeline. But collectorAuthenticationEnforced comes from teams[0]?.collectorAuthenticationEnforced, which is undefined here, so the bearertokenauth block at line 379 is skipped and the receiver accepts anything. On main the same state leaves apiKeys empty on the app image, so no receiver opens. .github/workflows/release.yml:1117-1142 relies on the collector never opening a keyless receiver. Fix: when the preset key is what makes apiKeys non-empty, enforce auth with it, for example collectorAuthenticationEnforced = teams[0]?.collectorAuthenticationEnforced ?? (teams.length === 0 && pushedPresetKey). Add a test that calls buildOtelCollectorConfig([]) with the flag set and asserts either that otlp/hyperdx has auth or that it is not attached.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
pulpdrew
left a comment
There was a problem hiding this comment.
LGTM, thanks for the contribution
Summary
On the app image, the OpAMP config ignores
INGESTION_API_KEY, so an external collector has to authenticate with the team's generated key. That key changes whenever the team is recreated, for example after the database is rebuilt, and the collector is locked out until someone copies the new key from Team Settings into its config.This adds an opt-in
ENABLE_INGESTION_API_KEY=true, in the same style asENABLE_DATADOG_RECEIVER. With it set,INGESTION_API_KEYis accepted alongside the team key, so a deployment can pin a key that survives a rebuild. Nothing changes when it is unset. I kept the existing all-in-one and dev gate as it is, since its security reasoning isn't written down anywhere. Happy to rename the variable, or to drop the gate instead if you'd prefer that.How to reproduce
Starting point: the app image (
HYPERDX_IMAGE=hyperdx,NODE_ENV=production) with the standalone collector in OpAMP supervisor mode, and collector authentication enforced for the team (the default for a new team).yarn devdoes not show the problem, becauseIS_DEValready honors the key. The new unit tests inopampController.test.tscover the same three cases.On
main:INGESTION_API_KEY=preset-keyon the API and restart it.Authorization: preset-key: it is rejected, andpreset-keyis missing from thebearertokenauth/hyperdxtokens in the OpAMP config.On this branch:
INGESTION_API_KEY=preset-keyandENABLE_INGESTION_API_KEY=trueand restart the API.main.How to test on Vercel preview
N/A, non-UI change.
References