Skip to content

fix(api): require INGESTION_API_KEY on the app image before any team exists - #3760

Merged
kodiakhq[bot] merged 4 commits into
ClickHouse:mainfrom
andrewdunndev:ai/ingestion-key-enforce-before-team
Nov 23, 2026
Merged

kodiakhq[bot] merged 4 commits into
ClickHouse:mainfrom
andrewdunndev:ai/ingestion-key-enforce-before-team

Conversation

@andrewdunndev

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3633, which merged before this fix reached its branch.

With ENABLE_INGESTION_API_KEY=true and no team created yet, the preset key is the only key, so the otlp/hyperdx receiver is attached. Authentication follows teams[0]?.collectorAuthenticationEnforced, though, and that is undefined when there is no team. The receiver then accepts data without authentication. Before #3633, the app image opened no receiver in that state.

  • No team, flag set: authentication is now enforced with the preset key.
  • A team exists: the team's own setting still decides, as before.
  • All-in-one and dev: unchanged.

The deep review on #3633 raised this.

How to reproduce

Starting point: the app image with the standalone collector in OpAMP supervisor mode, a fresh database with no team, and INGESTION_API_KEY=preset-key and ENABLE_INGESTION_API_KEY=true on the API.

  • On main: the OpAMP config attaches otlp/hyperdx with no auth and no bearertokenauth/hyperdx extension.
  • On this branch: both protocols carry the bearertokenauth/hyperdx authenticator with the preset key's variants. The new test in opampController.test.ts covers this case.

How to test on Vercel preview

N/A, non-UI change.

References

With ENABLE_INGESTION_API_KEY set and no team yet, the preset key made the otlp/hyperdx receiver attach, but authentication followed teams[0], which is absent, so the receiver accepted unauthenticated data.
@andrewdunndev
andrewdunndev requested a review from a team as a code owner November 22, 2026 02:41
@changeset-bot

changeset-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ec5a83e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/api Patch
@hyperdx/app Patch
@hyperdx/otel-collector Patch

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

@vercel

vercel Bot commented Nov 22, 2026

Copy link
Copy Markdown

@andrewdunndev is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

2 finding(s): 🔴 0 P0/P1 · 🟡 2 P2 · 🔵 0 P3

None could be anchored to changed lines; they are listed below.

Findings outside the changed lines

  • 🟡 P2 packages/api/src/opamp/controllers/__tests__/opampController.test.ts:23 — No test pins the 'team exists' branch when ENABLE_INGESTION_API_KEY is set → Add a case with ENABLE_INGESTION_API_KEY=true, INGESTION_API_KEY set, and [{ apiKey: 'k1', collectorAuthenticationEnforced: false }], and assert that otlp/hyperdx has no auth and there is no bearertokenauth/hyperdx extension. The new tests only cover buildOtelCollectorConfig([]). Rewriting line 201-202 as teams[0]?.collectorAuthenticationEnforced || config.ENABLE_INGESTION_API_KEY would still pass the suite, yet it overrides the team's own setting, which the PR says must keep deciding.
  • 🟡 P2 packages/api/src/opamp/controllers/opampController.ts:417 — Datadog auth comment is stale after this change → Update the comment at lines 417-423. It says auth is attached only "when team API keys exist and collector authentication is enforced", but collectorAuthenticationEnforced (lines 200-202) is now also true with no team when ENABLE_INGESTION_API_KEY is set. In that case only the preset INGESTION_API_KEY is enforced on the datadog receiver.

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.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. This is a tight, well-scoped security fix: the no-team + ENABLE_INGESTION_API_KEY state now enforces bearer-token auth on the otlp/hyperdx and datadog receivers instead of accepting unauthenticated ingest, and the new behavior is covered by two tests. Full state-space tracing (teams present/absent × collectorAuthenticationEnforced true/false/undefined × flag on/off × preset key set/empty) confirms no path regresses existing-team or all-in-one/dev behavior.

🟡 P2 — recommended

None.

🔵 P3 nitpicks (1)
  • packages/api/src/opamp/controllers/__tests__/opampController.test.ts:201 — no regression test asserting a team with collectorAuthenticationEnforced: false keeps auth disabled even when ENABLE_INGESTION_API_KEY is set, which is the boundary the ?? fallback must not override.
    • Fix: add a case passing one team with collectorAuthenticationEnforced: false plus the flag on, asserting no bearertokenauth/hyperdx extension is attached.

Reviewers (7): correctness, security, testing, maintainability, adversarial, previous-comments, project-standards.

Testing gaps:

  • Pre-existing (not introduced here): with no team, ENABLE_INGESTION_API_KEY=true, INGESTION_API_KEY unset, and ENABLE_DATADOG_RECEIVER=true, apiKeys is empty so the datadog receiver attaches without auth — the collectorAuthenticationEnforced flag is inert because the auth sub-block is gated on apiKeys.length > 0. Out of scope for this fix; worth a follow-up assertion.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

andrewdunndev and others added 2 commits November 21, 2026 21:52
…o-team key case

Also drop the INGESTION_API_KEY check from the no-team fallback: with no key, apiKeys stays empty and no auth is attached either way.

@pulpdrew pulpdrew 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.

LGTM

@kodiakhq
kodiakhq Bot merged commit c499769 into ClickHouse:main Nov 23, 2026
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants