Skip to content

fix: reject invalid numeric reliability configuration - #1450

Merged
kang-heewon merged 3 commits into
trunkfrom
fix/1399-reliability-numeric-validation
Jul 24, 2026
Merged

fix: reject invalid numeric reliability configuration#1450
kang-heewon merged 3 commits into
trunkfrom
fix/1399-reliability-numeric-validation

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Jul 22, 2026

Copy link
Copy Markdown
Member

Outcome

Rejects invalid retry, circuit-breaker, Lambda deadline, and Redis TTL numeric configuration before resolver, state, callback, sleep, telemetry, or Redis side effects. Invalid values now produce the public InvalidRetryConfigurationProblem with stable, non-sensitive metadata.

INVALID_RETRY_CONFIGURATION is classified as a non-retryable validation failure (HTTP 422), and generated Problem/API contracts plus release changesets are updated.

Fixes #1399

Verification

  • pnpm --filter @croco/retry-core test (266 tests)
  • pnpm --filter @croco/retry-core typecheck
  • pnpm --filter @croco/retry-core lint
  • pnpm --filter @croco/retry-core build
  • pnpm problem-registry:check (446 codes)
  • pnpm public-api:check (111 packages)
  • pnpm changeset-required:check -- --base origin/trunk --head HEAD
  • pre-push pnpm test and pnpm typecheck across the workspace

Review gates

  • Acceptance mapping: all affected numeric options have hostile matrices and accepted boundary cases.
  • Regression review: omitted/default behavior is preserved; custom backoff explicitly overrides inactive declarative backoff.
  • Adversarial review: found and closed eager @Retryable ordering and API documentation gaps; final re-review approved.

Residual risk

The API docs build completed all 112 tasks, but the local drift checker stability guard was repeatedly interrupted by concurrent generated-file formatting in the shared workspace. Generated retry and Problem API artifacts are included for CI verification.

Summary by CodeRabbit

  • 새 기능
    • 재시도, 백오프, 서킷 브레이커, Lambda 타임아웃, Redis TTL 설정에 대한 숫자 검증을 추가했습니다.
    • 잘못된 설정은 상태 변경이나 외부 작업 전에 즉시 거부됩니다.
    • 오류 진단에 옵션명, 요구 조건, 입력값 정보가 포함됩니다.
  • 버그 수정
    • 잘못된 재시도 설정 오류가 재시도 불가한 ValidationError로 변경되며, HTTP 422로 반환됩니다.
  • 문서
    • 새로운 오류 유형과 숫자 설정의 허용 범위, 기본값을 API 문서와 가이드에 반영했습니다.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kang-heewon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d6af86fb-0538-4353-b302-f0be41382124

📥 Commits

Reviewing files that changed from the base of the PR and between 61b4948 and 426509c.

⛔ Files ignored due to path filters (1)
  • packages/problems-core/src/generated/problem-code-registry.ts is excluded by !**/generated/**
📒 Files selected for processing (31)
  • .changeset/valid-retry-numeric-configuration.md
  • docs/problem-code-registry.json
  • packages/docs/src/content/docs/api/problems-core/src/classes/Problem.md
  • packages/docs/src/content/docs/api/problems-core/src/variables/CROCO_PROBLEM_CODE_REGISTRY.md
  • packages/docs/src/content/docs/api/retry-core/src/classes/InvalidRetryConfigurationProblem.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/BackoffOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/CircuitBreakerConfig.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/CircuitBreakerOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/RetryPolicyOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/RetryTemplateOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/RetryableOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/TimeoutGuardOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/type-aliases/RedisCircuitBreakerStoreOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/type-aliases/RetryNumericConstraint.md
  • packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
  • packages/retry-core/README.md
  • packages/retry-core/src/index.ts
  • packages/retry-core/src/libs/BackoffPolicy.ts
  • packages/retry-core/src/libs/CircuitBreaker.ts
  • packages/retry-core/src/libs/LambdaTimeoutGuard.ts
  • packages/retry-core/src/libs/RetryOrchestrator.ts
  • packages/retry-core/src/libs/RetryPolicy.ts
  • packages/retry-core/src/libs/RetryTemplate.ts
  • packages/retry-core/src/libs/Retryable.ts
  • packages/retry-core/src/libs/errors/RetryInfrastructureProblem.ts
  • packages/retry-core/src/libs/errors/index.ts
  • packages/retry-core/src/libs/numericValidation.ts
  • packages/retry-core/src/libs/stores/RedisCircuitBreakerStore.ts
  • packages/retry-core/src/tests/NumericConfiguration.spec.ts
  • public-api-surface.snapshot.json
  • tsconfig/contract-strict.baseline.json
📝 Walkthrough

Walkthrough

재시도 관련 숫자 옵션에 공통 검증을 도입하고, 잘못된 값은 상태 변경·콜백·sleep·Redis I/O 전에 ValidationError 기반 Problem으로 거부한다. 공개 export, 테스트, Problem 레지스트리와 API 문서도 이에 맞게 갱신된다.

Changes

숫자 검증 계약과 오류 모델

Layer / File(s) Summary
공통 검증 및 공개 Problem
packages/retry-core/src/libs/errors/*, packages/retry-core/src/libs/numericValidation.ts, packages/retry-core/src/index.ts
숫자 제약 유니온, 타이머 상한, 공통 검증 함수와 InvalidRetryConfigurationProblem이 추가된다. 오류는 422 ValidationError로 분류되고 옵션명·제약·수신값을 extensions에 담는다.

실행 경로 검증

Layer / File(s) Summary
재시도·서킷 브레이커 검증
packages/retry-core/src/libs/BackoffPolicy.ts, packages/retry-core/src/libs/CircuitBreaker.ts, packages/retry-core/src/libs/RetryTemplate.ts, packages/retry-core/src/libs/RetryOrchestrator.ts
백오프, 서킷 브레이커, 최대 시도 횟수의 숫자 설정을 생성·실행 전에 검증한다.
Retryable·Lambda·Redis 검증
packages/retry-core/src/libs/Retryable.ts, packages/retry-core/src/libs/LambdaTimeoutGuard.ts, packages/retry-core/src/libs/stores/RedisCircuitBreakerStore.ts
Retryable 옵션, Lambda 예약 시간·지연, Redis TTL을 공통 검증하고 유효성 확인 후 상태 접근 및 I/O를 수행한다.

검증 테스트

Layer / File(s) Summary
숫자 옵션 경계와 부작용 검증
packages/retry-core/src/tests/NumericConfiguration.spec.ts
유효하지 않은 값과 경계값을 각 실행 경로에서 검증하고, 콜백·resolver·상태 저장소·Lambda API·Redis I/O가 조기에 차단되는지 확인한다.

Problem 및 문서 동기화

Layer / File(s) Summary
레지스트리와 API 문서 갱신
docs/problem-code-registry.json, packages/docs/src/content/docs/api/..., packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
INVALID_RETRY_CONFIGURATION의 422·비재시도 메타데이터와 소스 위치를 갱신하고, 새 Problem 및 숫자 제약과 옵션 범위를 문서화한다.
패키지 안내와 릴리스 메타데이터
packages/retry-core/README.md, .changeset/valid-retry-numeric-configuration.md, tsconfig/contract-strict.baseline.json
숫자 검증 규칙과 Problem 목록을 README에 추가하고 patch 릴리스 및 계약 진단 기준을 갱신한다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant Retryable
  participant NumericValidation
  participant RetryInfrastructureProblem
  participant StateOrIO
  Caller->>Retryable: numeric retry configuration
  Retryable->>NumericValidation: assertValidRetryNumber(...)
  alt invalid configuration
    NumericValidation->>RetryInfrastructureProblem: create ValidationError
    RetryInfrastructureProblem-->>Caller: HTTP 422 Problem
  else valid configuration
    Retryable->>StateOrIO: access state, sleep, or Redis
  end
Loading

Possibly related PRs

  • croco-dev/framework#1222: Problem 레지스트리의 redaction 정책을 직렬화 및 오류 처리 경로에 적용한다.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 숫자형 신뢰성 설정의 잘못된 값 거부라는 핵심 변경을 정확히 요약합니다.
Linked Issues check ✅ Passed 백오프, 서킷브레이커, Lambda, Redis TTL에 대한 경계 검증과 호스틸 테스트, 안정적 Problem, 기본값 보존이 반영되었습니다.
Out of Scope Changes check ✅ Passed 변경 대부분이 검증 로직, 관련 테스트, API·문서·릴리스 메타데이터 갱신으로 목적 범위 안에 있습니다.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1399-reliability-numeric-validation

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.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 8.2μs 30.0ms 8.2μs +0.0% -
CrocoApp lambdaHandler (10 controllers) 258.3μs 50.0ms 258.4μs -0.0% -
Lambda cold-start simulation 406.2μs 80.0ms 418.1μs -2.9% -
Lambda cold-start with headers 327.2μs 80.0ms 369.7μs -11.5% -
Lambda cold-start with binary body 279.7μs 80.0ms 339.1μs -17.5% -
Lambda cold-start with query params 243.7μs 80.0ms 301.3μs -19.1% -
Lambda cold-start with authorizer context 246.2μs 80.0ms 299.8μs -17.9% -
Lambda cold-start realistic scenario 242.3μs 80.0ms 299.2μs -19.0% -
EventBusConfig.start (10 handlers) 1.6μs 10.0ms 1.4μs +14.0% -
EventPublisher.publishNow single event 2.1μs 2.0ms 1.7μs +26.1% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.1μs -15.0% -
Container.get singleton (cold) 60.6μs 5.0ms 70.3μs -13.7% -
Container.register × 50 components 3.3ms 10.0ms 3.2ms +1.1% -
Container.validate (50 components) 3.7ms 20.0ms 3.4ms +10.0% -
Container.get singleton (warm) 1.7μs 500.0μs 1.6μs +3.6% -
TelemetryRuntime.init (lambda preset) 2.3μs 200.0ms 1.1ms -99.8% -
lambdaPreset config creation 1.3μs 2.0ms 1.4μs -8.2% -

Updated: 2026-07-24T07:12:49.143Z · Commit: 3073e3c

@kang-heewon
kang-heewon force-pushed the fix/1399-reliability-numeric-validation branch 4 times, most recently from c5c0671 to 61b4948 Compare July 23, 2026 01:08

@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: 3

🤖 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 `@packages/retry-core/README.md`:
- Around line 57-61: README의 숫자형 신뢰성 옵션 설명을 수정해 maxDelay, openDuration, circuit
breaker timeout이 최대값 이하의 1 이상 정수임을 명시하세요. 또한 양의 안전 정수 옵션 목록에 successThreshold를
추가하고, 기존의 reserve/delay 및 기타 검증 설명은 유지하세요.

In `@packages/retry-core/src/tests/NumericConfiguration.spec.ts`:
- Around line 215-218: Update the Redis I/O assertions in the affected
NumericConfiguration test to also verify that incr, del, eval, and scan were not
called, alongside the existing get, set, and expire checks. Ensure every Redis
mock method is covered so all Redis access paths are confirmed blocked.
- Around line 1-2: Initialize the DI Container before each test in
NumericConfiguration.spec.ts by adding the project-standard beforeEach reset
pattern alongside the existing Vitest imports and test setup. Ensure every test
starts with a clean container state without changing the test assertions or
configuration behavior.
🪄 Autofix (Beta)

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: c1caa7af-232a-4b45-b7e3-c35f2c6f69d1

📥 Commits

Reviewing files that changed from the base of the PR and between e4bfcb2 and 61b4948.

⛔ Files ignored due to path filters (1)
  • packages/problems-core/src/generated/problem-code-registry.ts is excluded by !**/generated/**
📒 Files selected for processing (31)
  • .changeset/valid-retry-numeric-configuration.md
  • docs/problem-code-registry.json
  • packages/docs/src/content/docs/api/problems-core/src/classes/Problem.md
  • packages/docs/src/content/docs/api/problems-core/src/variables/CROCO_PROBLEM_CODE_REGISTRY.md
  • packages/docs/src/content/docs/api/retry-core/src/classes/InvalidRetryConfigurationProblem.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/BackoffOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/CircuitBreakerConfig.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/CircuitBreakerOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/RetryPolicyOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/RetryTemplateOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/RetryableOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/interfaces/TimeoutGuardOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/type-aliases/RedisCircuitBreakerStoreOptions.md
  • packages/docs/src/content/docs/api/retry-core/src/type-aliases/RetryNumericConstraint.md
  • packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
  • packages/retry-core/README.md
  • packages/retry-core/src/index.ts
  • packages/retry-core/src/libs/BackoffPolicy.ts
  • packages/retry-core/src/libs/CircuitBreaker.ts
  • packages/retry-core/src/libs/LambdaTimeoutGuard.ts
  • packages/retry-core/src/libs/RetryOrchestrator.ts
  • packages/retry-core/src/libs/RetryPolicy.ts
  • packages/retry-core/src/libs/RetryTemplate.ts
  • packages/retry-core/src/libs/Retryable.ts
  • packages/retry-core/src/libs/errors/RetryInfrastructureProblem.ts
  • packages/retry-core/src/libs/errors/index.ts
  • packages/retry-core/src/libs/numericValidation.ts
  • packages/retry-core/src/libs/stores/RedisCircuitBreakerStore.ts
  • packages/retry-core/src/tests/NumericConfiguration.spec.ts
  • public-api-surface.snapshot.json
  • tsconfig/contract-strict.baseline.json
💤 Files with no reviewable changes (1)
  • tsconfig/contract-strict.baseline.json

Comment thread packages/retry-core/README.md
Comment thread packages/retry-core/src/tests/NumericConfiguration.spec.ts Outdated
Comment thread packages/retry-core/src/tests/NumericConfiguration.spec.ts
@kang-heewon
kang-heewon force-pushed the fix/1399-reliability-numeric-validation branch from c6a3b4e to e46a2f3 Compare July 24, 2026 05:57
@kang-heewon
kang-heewon force-pushed the fix/1399-reliability-numeric-validation branch from e46a2f3 to 426509c Compare July 24, 2026 07:04
@kang-heewon
kang-heewon merged commit b65ed66 into trunk Jul 24, 2026
15 of 16 checks passed
@kang-heewon
kang-heewon deleted the fix/1399-reliability-numeric-validation branch July 24, 2026 08:06
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.

[retry-core] Reject invalid numeric reliability configuration

1 participant