Skip to content

fix: make aggregate health reflect dependencies - #1784

Merged
kang-heewon merged 4 commits into
trunkfrom
fix/1697-aggregate-health
Aug 9, 2026
Merged

fix: make aggregate health reflect dependencies#1784
kang-heewon merged 4 commits into
trunkfrom
fix/1697-aggregate-health

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Aug 9, 2026

Copy link
Copy Markdown
Member

Outcome

/health now evaluates checks registered through HealthCheckRegistry.register() and returns the sanitized aggregate health contract. Failed, thrown, or timed-out dependency checks produce status: down with HTTP 503, while /health/live remains a lightweight dependency-independent process probe.

Health and readiness details share explicit response bounds: strings are capped at 100 characters, each object or array at 50 entries, and each check at 500 traversed nodes and 10,000 characters. Sensitive keys are redacted, stack/cause and non-JSON callable values are omitted, and serialization hooks cannot bypass those bounds.

Fixes #1697

Verification

  • pnpm problem-registry:check — 597/597 discoveries passed
  • pnpm --filter @croco/transports-http test — 33 files, 435 tests passed
  • pnpm --filter @croco/transports-http typecheck — passed
  • pnpm --filter @croco/transports-http lint — passed with 0 warnings/errors
  • pnpm strict-contract-typecheck — 503 baseline diagnostics matched
  • Generated-app smoke unit suite — 40 tests passed
  • Pre-push workspace test — 236/236 tasks passed
  • Pre-push workspace typecheck — 235/235 tasks passed

Review gates

  • Correctness and regression — PASS. Route coverage proves healthy, failed, timed-out/aborted, redacted, and bounded aggregate responses; liveness remains independent.
  • API, security, compatibility, and release — PASS. Documentation defines the aggregate contract and bounds; a minor changeset reflects the public HTTP contract change on the 0.x package line.
  • Maintainability and minimality — PASS. The route reuses the existing generic registry and shared HTTP sanitizer without changing readiness registration semantics.
  • Independent adversarial review — PASS after fixes. Reviews identified stale compatibility docs, unbounded nested traversal, configurable string-bound escape, and callable serialization hooks. All were fixed with regression coverage, and the final re-review approved.

Residual risk

Consumers that treated /health as unconditional liveness must use /health/live; this intentional compatibility change is documented and receives a minor release on the package 0.x version line.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

등록된 health check가 집계 /health 응답에 반영됩니다. 실패 또는 timeout 시 503을 반환합니다. 결과 상세 정보는 제한하고 민감 정보를 마스킹합니다. /health/live는 독립적인 liveness 확인으로 유지됩니다.

Changes

집계 Health 엔드포인트

Layer / File(s) Summary
Health 결과 sanitization
packages/transports-http/src/libs/operationalEndpoints.ts
Health 결과 상세 정보에 문자열·컬렉션 크기 제한과 재귀적 민감 정보 마스킹을 적용합니다.
집계 endpoint 연결
packages/transports-http/src/libs/CrocoApp.ts, .changeset/aggregate-http-health.md, packages/transports-http/README.md, docs/troubleshooting/diagnostics.md
/health가 등록된 health check 결과를 반환합니다. 상태가 down이면 503을 반환합니다. readiness와 liveness endpoint의 실행 범위와 응답 계약을 문서화합니다.
endpoint 계약 검증
packages/transports-http/src/tests/HealthCheck.spec.ts, packages/transports-http/src/tests/OperationalEndpoints.spec.ts, scripts/create-croco-app-generated-smoke.mts
정상, 실패, timeout, abort, 결과 제한, 민감 정보 마스킹 및 aggregate 응답 구조를 검증합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CrocoApp
  participant HealthCheckRegistry
  participant sanitizeHealthCheckResult
  Client->>CrocoApp: GET /health
  CrocoApp->>HealthCheckRegistry: 등록된 health check 실행
  HealthCheckRegistry-->>CrocoApp: health aggregate 결과
  CrocoApp->>sanitizeHealthCheckResult: 결과 sanitization
  sanitizeHealthCheckResult-->>CrocoApp: 제한 및 마스킹된 결과
  CrocoApp-->>Client: 200 또는 503 응답
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed [1697] /health 집계, 실패·타임아웃 시 503, 독립적인 /health/live, 상세 정보 제한·redaction 및 관련 테스트를 모두 반영합니다.
Out of Scope Changes check ✅ Passed 변경 사항은 aggregate health 계약, sanitization, 테스트, 문서 및 관련 smoke 검증 범위에 포함됩니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 의존성 상태를 반영하도록 aggregate health를 수정하는 이 PR의 주요 변경 사항을 정확하고 간결하게 설명합니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1697-aggregate-health

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/aggregate-http-health.md:
- Line 2: Update the changeset entry for `@croco/transports-http` in
aggregate-http-health.md from patch to minor to reflect the breaking public HTTP
contract changes while the package remains on the 0.x version line.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a777813a-c665-419c-af43-7e5655abe9ba

📥 Commits

Reviewing files that changed from the base of the PR and between 651bc2a and ef5065a.

📒 Files selected for processing (7)
  • .changeset/aggregate-http-health.md
  • docs/troubleshooting/diagnostics.md
  • packages/transports-http/README.md
  • packages/transports-http/src/libs/CrocoApp.ts
  • packages/transports-http/src/libs/operationalEndpoints.ts
  • packages/transports-http/src/tests/HealthCheck.spec.ts
  • packages/transports-http/src/tests/OperationalEndpoints.spec.ts

Comment thread .changeset/aggregate-http-health.md Outdated
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 44.2μs 30.0ms 8.2μs +441.2% -
CrocoApp lambdaHandler (10 controllers) 1.9ms 50.0ms 258.4μs +644.6% -
Lambda cold-start simulation 1.8ms 80.0ms 418.1μs +339.1% -
Lambda cold-start with headers 1.5ms 80.0ms 369.7μs +310.8% -
Lambda cold-start with binary body 1.5ms 80.0ms 339.1μs +346.9% -
Lambda cold-start with query params 1.5ms 80.0ms 301.3μs +401.4% -
Lambda cold-start with authorizer context 1.5ms 80.0ms 299.8μs +412.2% -
Lambda cold-start realistic scenario 1.5ms 80.0ms 299.2μs +403.5% -
EventBusConfig.start (10 handlers) 1.7μs 10.0ms 1.4μs +17.4% -
EventPublisher.publishNow single event 1.9μs 2.0ms 1.7μs +13.1% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.1μs -11.2% -
Container.get singleton (cold) 89.5μs 5.0ms 70.3μs +27.4% -
Container.register × 50 components 3.3ms 10.0ms 3.2ms +2.6% -
Container.validate (50 components) 3.7ms 20.0ms 3.4ms +10.6% -
Container.get singleton (warm) 1.7μs 500.0μs 1.6μs +2.5% -
TelemetryRuntime.init (lambda preset) 2.2μs 200.0ms 1.1ms -99.8% -
lambdaPreset config creation 1.5μs 2.0ms 1.4μs +4.3% -

Updated: 2026-08-09T09:32:25.515Z · Commit: 8719c22

@kang-heewon

Copy link
Copy Markdown
Member Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
✅ Action performed

Comments resolved and changes approved.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/transports-http/src/libs/operationalEndpoints.ts (2)

254-282: 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

전체 순회 비용을 별도로 제한하십시오.

Line [254-282]collectionLimit은 각 컬렉션의 출력 항목 수만 제한합니다. 재귀 호출마다 같은 한도가 다시 적용되므로 각 레벨에 50개 항목이 있는 깊이 5 구조는 약 50^5개의 leaf 경로를 방문할 수 있습니다. Object.entriesslice 전에 모든 object key를 materialize합니다. 큰 또는 중첩된 details가 반환되면 /health 요청이 CPU와 메모리를 과도하게 사용하여 응답 지연 또는 프로세스 자원 고갈을 일으킬 수 있습니다. 전체 재귀에 공유되는 node/byte budget을 추가하고, 객체는 한도에 도달하면 즉시 순회를 중단하십시오. Flat object와 공유 하위 객체를 사용하는 회귀 테스트도 추가하십시오.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/transports-http/src/libs/operationalEndpoints.ts` around lines 254 -
282, Update redactValue to enforce a shared node/byte budget across the entire
recursive traversal, rather than resetting collectionLimit at each level. Avoid
materializing all object keys with Object.entries before limiting; iterate
entries incrementally and stop immediately when the shared budget is exhausted,
returning the existing truncation marker as appropriate. Preserve redaction
behavior while ensuring both flat large objects and shared nested-object graphs
are bounded, and add regression tests covering those cases.

212-213: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

health 상세 문자열 한도의 상한을 적용하십시오.

path: packages/transports-http/src/libs/operationalEndpoints.ts:212-213에서 health 상세 문자열 제한이 messageLimit에 전적으로 의존합니다. messageLimit은 100자가 넘어 설정할 수 있으므로, health 상세에는 health 전용 상한을 사용하십시오.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/transports-http/src/libs/operationalEndpoints.ts` around lines 212 -
213, Update the health detail configuration near stringLimit and collectionLimit
so stringLimit uses a health-specific maximum rather than relying solely on
messageLimit. Clamp messageLimit to the established health detail string-limit
constant, preserving the existing collectionLimit behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/transports-http/src/libs/operationalEndpoints.ts`:
- Around line 254-282: Update redactValue to enforce a shared node/byte budget
across the entire recursive traversal, rather than resetting collectionLimit at
each level. Avoid materializing all object keys with Object.entries before
limiting; iterate entries incrementally and stop immediately when the shared
budget is exhausted, returning the existing truncation marker as appropriate.
Preserve redaction behavior while ensuring both flat large objects and shared
nested-object graphs are bounded, and add regression tests covering those cases.
- Around line 212-213: Update the health detail configuration near stringLimit
and collectionLimit so stringLimit uses a health-specific maximum rather than
relying solely on messageLimit. Clamp messageLimit to the established health
detail string-limit constant, preserving the existing collectionLimit behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eac958c6-f207-44f4-bfca-d7fb9d23ad66

📥 Commits

Reviewing files that changed from the base of the PR and between ef5065a and d6b3025.

📒 Files selected for processing (3)
  • .changeset/aggregate-http-health.md
  • packages/transports-http/src/libs/operationalEndpoints.ts
  • scripts/create-croco-app-generated-smoke.mts

@kang-heewon
kang-heewon force-pushed the fix/1697-aggregate-health branch 2 times, most recently from db17e43 to dae84ca Compare August 9, 2026 06:47
@kang-heewon
kang-heewon force-pushed the fix/1697-aggregate-health branch from dae84ca to 4a34364 Compare August 9, 2026 09:22
@kang-heewon
kang-heewon merged commit 8bb215f into trunk Aug 9, 2026
12 checks passed
@kang-heewon
kang-heewon deleted the fix/1697-aggregate-health branch August 9, 2026 17:38
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.

[transports-http] Make aggregate /health reflect registered health checks

1 participant